1.

Solve : How to create a file sorter!?

Answer»

Let's say you had more then 15,000 files.
You wanted to sort them.
They were all unorganized. Documents, pictures, music, videos in one folder.
This is how to make a file sorter that will organize your files!
You will need to know these commands:
echo (Just for the starting @echo off to prevent batch input from showing)
mkdir (Only for the folders.)
copy (Very important.. This will copy the files!)
First, we add our first line: @echo off.
Then we make 4 folders: Documents, Pictures, Music, and Videos.
@echo off
mkdir Documents
mkdir Pictures
mkdir Music
mkdir Videos
If you wanted them in a directory in the D drive called "Files" do this:
@echo off
mkdir D:\Files\Documents
mkdir D:\Files\Pictures
mkdir D:\Files\Music
mkdir D:\Files\Videos
Now to get to the copying business!
To copy all text files and Word documents to the Documents folder:
copy *.txt *.docx Documents
If you have old Word documents, add *.doc.
Wait a minute, what about *.rtf?
And let's get the pictures
copy *.gif *.png *.tif *.tiff *.bmp Pictures
For music, there's not that much..
copy *.wav *.WMA *.mp3 Music
Now, videos..
copy *.mp4 *.wmv Videos
Use the same way you did for making directories inside other directories "and even drives!" to put the files in a different directory.
The final code would be:
@echo off
mkdir Documents
mkdir Pictures
mkdir Music
mkdir Videos
copy *.txt *.docx Documents
copy *.gif *.png *.tif *.tiff *.bmp Pictures
copy *.wav *.wma *.mp3 Music
copy *.mp4 *.wmv Videos


Which OS supports a copy command with multiple filespecs?EHM.. I think Windows XP and up. Or 2K and up? I don't know Quote from: simplyTechy100 on February 17, 2014, 04:59:42 AM

Ehm.. I think Windows XP or 2K???
No Version of Windows allows you to specify multiple source files with the copy command- except through the use of wildcards with the one source parameter that can be used.

I was using wildcards in the original post Aww... The script has broken downhill...
The "copy" should be "move" Quote from: simplyTechy100 on February 17, 2014, 05:10:22 AM
I was using wildcards in the original post
Quote from: BC_Programmer on February 17, 2014, 05:08:42 AM
No Version of Windows allows you to specify multiple source files with the copy command- except through the use of wildcards with the one source parameter that can be used.
You can only specify one source parameter. If you specify more than one source parameter you will receive a "The Syntax of the command is incorrect". All of your examples specify multiple destination filenames and do not work as a result.

Quote from: simplyTechy100 on February 17, 2014, 05:12:01 AM
Aww... The script has broken downhill...
The "copy" should be "move"
Move has the same limitation, and emits the same error message if you try it.Quote from: simplyTechy100 on February 17, 2014, 04:59:42 AM
Ehm.. I think Windows XP and up. Or 2K and up? I don't know
Sure glad you tested your code before posting it. It's true that move and copy do not accept multiple file specs, HOWEVER you can use the for instruction to feed those commands the file specs one at a TIME:

Code: [Select]@echo off
mkdir Documents
mkdir Pictures
mkdir Music
mkdir Videos

for %%i in (*.txt *.docx) do copy "%%i" Documents
for %%i in (*.gif *.png *.tif *.tiff *.bmp) do copy "%%i" Pictures
for %%i in (*.wav *.wma *.mp3) do copy "%%i" Music
for %%i in (*.mp4 *.wmv) do copy "%%i" Videos

Be aware those MD commands will create sub-folders under the current folder.

Maybe you meant to do this.
Code: [Select]for /f "delims=" %%G in ('dir /a-d /b *.txt *.doc') do copy "%%~G" DocsQuote from: Squashman on February 17, 2014, 06:10:18 AM
Sure glad you tested your code before posting it.

+1

Both methods worked so I went with simple.

Quote from: Sidewinder on February 17, 2014, 07:01:07 AM
Both methods worked so I went with simple.


Your code is PROBABLY the preferred method. Just force of habit for me to always use the DIR command.Thank you everyone.
I didn't even know the command for Thanks guys. Do this:
Code: [Select]@echo off
md Documents
md Pictures
md Music
md Videos
md Misc
for %%i in (*.txt *.doc *.rtf *.docx) do copy "%%i" Documents
for %%i in (*.gif *.png *.bmp *.tif *.tiff) do copy "%%i" Pictures
for %%i in (*.wav *.mp3 *.wma) do copy "%%i" Music
for %%i in (*.mp4 *.wmv) do copy "%%i" Videos
for %%i in (*.exe *.bat *.com *.zip *.pif *.dll *.bak) do copy "%%i" MiscI added a Misc folder in case you need more stuff copied


Discussion

No Comment Found