rename - Renaming files in a folder conditionally with batch file -
let's start explaining want do.
i have folder photos camera. named this: dsc_0030.jpg dsc_0030 (2).jpg dsc_0031.jpg dsc_0030 (2).jpg , on.
this annoying when try through them because ones (2) memory card , taken @ later date.
sorting date not seem work either. photos not own camera can't re-import them different folders.
so idea batch file this, not know syntaxes.
foreach(file in "folderpath") { if (instr(file.name, "(2)")) { file.name = "2 " + file.name; } else { file.name = "1 " + file.name; } }
not tested
@echo off ::: set correct path ::: set "photos=c:\photos" setlocal enabledelayedexpansion %%a in ("%photos%\*(?).???") ( set "filename=%%~na" set "wb=!filename:~0,-3!" set "number=!filename:~-2,-1!" rem :::: remove echo word if file name looks ok ::: echo ren "%%~fa" "!number!-!wb!%%~xa" )
Comments
Post a Comment