Reputation: 304
I would like to sort and move files with batch coding, is that possible?
Let's say, I have following files lists in folder :
A1.txt
C1.txt
A1.pdf
C1.doc
A1.doc
B1.pdf
B1.txt
C1.pdf
B1.doc
When I run the DOS batch file without parameters and coding file name in batch scripting, The batch file will sort the file and create folder according to file name.
"A1.txt A1.pdf A1.doc" should move in folder called A1 which is automatically, likewise, B1 and C1 folder should be created, the files should be moved in their folder.
Upvotes: 1
Views: 656
Reputation: 385657
If you actually want a Windows batch file,
for %%q in (*) do (
if not exist "%%~nq" md "%%~nq"
move "%%q" "%%~nq"
)
Run "help for" for documentation on "for" and the "~" notation.
(Written for a batch file. If you want to run the command from the prompt, use one "%" instead of two.)
Upvotes: 5