Script to move folders based on folder name

May 15, 2010 at 14:56:37
Specs: Windows 7
Im looking to have a script scan directory (G:\downloads) and look for specific words in the sub folders (xvid, dvdr, 1080p, etc) and based on the specific folder name (rounders.xvid, rounders.dvdr, rounders.1080p, etc) it will move the folder and its contents to H:\xvid, H:\dvdr, H:\1080p.

See More: Script to move folders based on folder name

Report •

May 17, 2010 at 08:11:27
for %%a in (xvid dvdr 1080p etc) do for /d %%b in ("G:\downloads\*%%a*") do move "%%~Fb" "h:\%%a\%%b"

Report •

May 19, 2010 at 20:53:10
Im confused about the (xvid dvdr 1080p etc) part of the code....

Is this something that I would need to specify in the script based on what I would be looking to move?

For instance for xvid:

for %%a in xvid do for /d %%b in ("G:\downloads\*%%a*") do move "%%~Fb" "h:\%%a\%%b"

Report •

May 20, 2010 at 06:14:05
It's a loop outside of a loop. it'll look for 'xvid', then 'dvdr', then '1080p', then 'etc'

Report •

Related Solutions

May 20, 2010 at 19:46:33
So I've gotten it to copy data but had to modify the script a little... now Im running into one minor issue. It moves the data UNDER the folder but doesnt retain the file folder structure. Meaning it will find G:\downloads\720p.this.folder\ but it will copy the folder and its contents to the ROOT of H:\-= Movies\-= 720p and NOT create the folder structure 720p.this.folder. So it should look like "H:\-= Movies\-= 720p\720p.this.folder\contents of files and folder" but it doesnt

Here's the script I've been testing with

for %%a in (720p) do for /d %%b in ("G:\downloads\*%%a*") do robocopy /move /E "%%~Fb" "H:\-= Movies\-= 720p"\

I tried to add %%b at the end of H:\-= Movies\-= 720p\%%b"\ but I get an error because it wants to copy H:\-= Movies\-= 720p\G:\downloads\720p.this.folder\ and I just want it to copy the 720p.this.folder. Im sure/hope its something simple....

I had to use robocopy to move between drive letters since I was getting an access denied.

Report •

May 24, 2010 at 14:30:28
Yeah, I don't use robocopy, as I don't have a copy of it. As such, I can't support scripts dependent on it.

Maybe someone else will pick this up.

Report •

May 24, 2010 at 14:51:56
Its not a robocopy script error...

What I want it to copy is the actual folder that the script you wrote finds. If I add a %%a to the end, it just creates a 720p folder, based on the (720p) in the script. So if the script could do a MKDIR of whatever %%a is so it will create that folder and then copy the data to that specific folder, that would work. Or even output the folder name that it finds and then copies that specific DIR name to the location? I just dont know where to insert the MKDIR or if thats even possible?

Report •

Ask Question