create windows 8 batch file to copy, rename and save files from sub directories recursively -


i'm trying copy thousands of image files , rename them name of folder in. file structure is:-

c:\pictures\kitcam\1\master_01.jpg c:\pictures\kitcam\1\master_02.jpg c:\pictures\kitcam\2\master_01.jpg c:\pictures\kitcam\3\master_01.jpg c:\pictures\kitcam\3001\master_01.jpg 

i create new directory c:\pictures\kitcam\all , copy , rename files above following naming convention:-

c:\pictures\kitcam\all\[directoryname]_filename]
(pad directory name 4 digits director name 1 becomes 0001 etc)

for example:-

c:\pictures\kitcam\all\0001_master_01.jpg  

jonathan

@echo off &setlocal set "startfolder=c:\pictures\kitcam" set "targetfolder=c:\pictures\kitcam\all"  /r "%startfolder%" %%a in (*.jpg) (     set "fname=%%~nxa"     set "fpath=%%~fa"     /f "delims=" %%b in ("%%~dpa.") set "nname=000%%~nxb"     setlocal enabledelayedexpansion     echo move "!fpath!" "%targetfolder%\!nname:~-4!_!fname!"     endlocal ) 

look @ output , remove word echo before move if looks good.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -