Solved Batch Script for Organizing Clips(.mp4) into Shot Folders

May 5, 2015 at 16:24:57
Specs: Windows 7
How's it going!

I need help creating a batch script that can look at a file name, create a folder based off of a part of the name and then move it to that folder.
It would need to check and see if the Shot "x" folder has already been created and if it has it just moves the file over rather than trying to create a new folder.

Example:

C:/Desktop/Cameras/Camera 01/Camera 01 Shot 01
C:/Desktop/Cameras/Camera 02/Camera 02 Shot 01
C:/Desktop/Cameras/Camera 03/Camera 03 Shot 01

and

C:/Desktop/Cameras/Camera 01/Camera 01 Shot 02
C:/Desktop/Cameras/Camera 02/Camera 02 Shot 02
C:/Desktop/Cameras/Camera 03/Camera 03 Shot 02

The script would Run and the structure would look like this:

C:/Desktop/Cameras/Shot 01/Camera 01 Shot 01
C:/Desktop/Cameras/Shot 01/Camera 02 Shot 01
C:/Desktop/Cameras/Shot 01/Camera 03 Shot 01

and

C:/Desktop/Cameras/Shot 02/Camera 01 Shot 02
C:/Desktop/Cameras/Shot 02/Camera 02 Shot 02
C:/Desktop/Cameras/Shot 02/Camera 03 Shot 02

I've got 40+ Cameras with 100+ shots and it takes me HOURS to do this by hand.
I've searched online and tried comping together something but I just can't seem to get it to do what I want (and I'm having a damned hard time figuring out which each line does)

Thanks for any help!


See More: Batch Script for Organizing Clips(.mp4) into Shot Folders

Report •


✔ Best Answer
May 6, 2015 at 13:11:50
I Got it!

@echo off>test.bat & setlocal enabledelayedexpansion
:: substitute "move" for "copy" at your discretion.
:: the textfile JD2 is primarily for debugging and tracking purposes...
:: It could be eliminated.
:: root directory used to avoid confusion. TEST.BAT should be created there.
cd \
dir /s /b c:\desktop\cameras\*shot* | sort /+40 > jd2
for /f "tokens=3-5" %%a in (jd2) do (
>>test.bat echo md "c:\desktop\Shots\%%b %%~nc" 2>nul
>>test.bat echo copy "c:\Desktop\Cameras\Camera %%a\Camera %%a %%b %%c" "c:\Desktop\Shots\%%b %%~nc\Camera %%a %%b %%c"
)
:: rem now look at test.bat and see if it looks ok before running it.



#1
May 5, 2015 at 22:55:03
It's not so hard, but it's the details that always kill us. Here's a very rough prototype - NOT tested but non-destructive. (Didn't have time to create the file structure, just used text rendition)

@echo off>test.bat & setlocal enabledelayedexpansion
:: substitute "move" for "copy" at your discretion.
:: the textfile JD2 is primarily for debugging and tracking purposes...
:: It could be eliminated.

:: root directory used to avoid confusion. TEST.BAT should be created there.
cd \
dir /s /b c:\desktop\cameras\*shot* | sort /+40 > jd2
for /f "tokens=3-5" %%a in (jd2) do (
>>test.bat echo md "c:\desktop\cameras\%%a %%b" 2>nul
>>test.bat echo copy "c:\desktop\cameras\camera %%a\%%b %%c" "c:\desktop\cameras\%%b %%c\camera %%a %%b %%c"
)
rem now look at test.bat and see if it looks ok before running it.


Report •

#2
May 6, 2015 at 09:42:39
Thanks for the quick response!

This is definitely on the right track, but here's the issue:

In my test folder I only have 5 shots per each camera folder. (I still have 40 cameras)
The test.bat is creating folders: Shot 01, Shot 02, Shot 03... -> Shot 40
I need it to only create a folder for the shots that exist, and if the folder has already been created, to just move (copy for test purposes) to the already existing folder.
Also I ran test.bat just to see what would happen and nothing was copied into the folders.

Thank you!


Report •

#3
May 6, 2015 at 09:59:09
This is the output I'm getting in test.bat:

md "c:\desktop\cameras\01 Shot"
copy "c:\desktop\cameras\camera 01\Shot 1.MP4" "c:\desktop\cameras\Shot 1.MP4\shot 01 Shot 1.MP4"

I think i want this to read:

md "c:\desktop\cameras\01 Shot" (not sure about this line)
copy "c:\desktop\cameras\camera 01\Camera 1 Shot 1.MP4" "c:\desktop\Shots\Shot 1\Camera 1 Shot 1.MP4"

Does that make sense?

message edited by jdleyden


Report •

Related Solutions

#4
May 6, 2015 at 13:11:50
✔ Best Answer
I Got it!

@echo off>test.bat & setlocal enabledelayedexpansion
:: substitute "move" for "copy" at your discretion.
:: the textfile JD2 is primarily for debugging and tracking purposes...
:: It could be eliminated.
:: root directory used to avoid confusion. TEST.BAT should be created there.
cd \
dir /s /b c:\desktop\cameras\*shot* | sort /+40 > jd2
for /f "tokens=3-5" %%a in (jd2) do (
>>test.bat echo md "c:\desktop\Shots\%%b %%~nc" 2>nul
>>test.bat echo copy "c:\Desktop\Cameras\Camera %%a\Camera %%a %%b %%c" "c:\Desktop\Shots\%%b %%~nc\Camera %%a %%b %%c"
)
:: rem now look at test.bat and see if it looks ok before running it.


Report •

Ask Question