Owners of Nokia Lumia 1020 know it can be set to store captured photos at full resolution, but the reduced size photos are also stored. I would like to have a script to automatically delete all the low resolution versions.
The filenames are kind of the following:
WP_20150303_17_20_38_Pro.jpg WP_20150303_17_20_38_Pro__highres.jpg WP_20150303_17_21_21_Pro.jpg WP_20150303_17_21_21_Pro__highres.jpg WP_20150303_17_21_32_Pro.jpg WP_20150303_17_21_32_Pro__highres.jpg WP_20150303_17_22_47_Pro.jpg WP_20150303_17_22_47_Pro__highres.jpg WP_20150303_17_28_14_Pro.jpg WP_20150303_17_28_14_Pro__highres.jpg I could delete *_pro.jpg, but then there is a risk that what if there is no high resolution version at all. How can I write a script that would first check if there is a highres file present and only then delete lowresolution version?
2 Answers
Create a batch file. Start here: Loop command: against the results of another command and here: Command Line arguments (Parameters)
For /F "tokens=*" %%G in ('dir /b *_pro.jpg') do ( echo %%~dpnG ) Now you could change echo %%~dpnG to
if exist "%%~dpnG__highres.jpg" echo del "%%~dpnxG" or even to
if exist "%%~dpnG__highres.jpg" ( echo del "%%~dpnxG" ) else ( echo retain %%~dpnxG ) Thoroughly check the output (better twice) and substitute echo del with del.
Add /s switch to dir command as follows: dir /b /s *_pro.jpg to treat files in subfolders as well.
The .bat file I use:
@Echo off For /F "tokens=*" %%G in ('dir /s /b *_pro.jpg') do ( if exist "%%~dpnG__highres.jpg" ( echo delete %%~dpnxG ) else ( echo retain %%~dpnxG ) ) Echo. Echo _________________________________________________ Echo. Echo Do you really want to delete these files (Y/N)? CHOICE /C YN /N IF ERRORLEVEL 2 goto doend IF ERRORLEVEL 1 goto doerase exit :doerase For /F "tokens=*" %%G in ('dir /s /b *_pro.jpg') do ( if exist "%%~dpnG__highres.jpg" ( del "%%~dpnxG" ) else ( REM echo retain %%~dpnxG ) ) :doend pause