Page 1 of 1
Need help running code to run on many selected files
Posted: 04 Mar 2018 18:42
by OM3
I have this code I modified from some other code I have:
Code: Select all
REM This code removes all Exif on selected files - should be images of course
REM Assuming you have Image Magick installed - this is the command that is used
REM @echo off
:loop
REM convert <input file> -strip <output file>
convert "%~1" -strip "%~1"
shift
if not "%~1"=="" goto :loop
pause
All the REM's are intentional above.
I'm trying to use Image Magick command covert to remove Exif data for images that I select.
The batch file, I put in SendTo directory. I right click many files that I want the code to work on and then choose my batch file from the SendTo folder.
The code works fine for something else I code (with help given on this forum).
What am I doing wrong?
Thanks.
Re: Need help running code to run on many selected files
Posted: 04 Mar 2018 19:33
by ShadowThief
What are you expecting it to do, and what is it actually doing?
Re: Need help running code to run on many selected files
Posted: 04 Mar 2018 20:31
by Squashman
How many files are you selecting?
Re: Need help running code to run on many selected files
Posted: 08 Mar 2018 13:27
by OM3
thanks for the replies guys.
let's say i have 10 files. i choose 5 of these.
for each of these 5, i want this command to be run:
convert abc.jpg -strip abc.jpg
in this example, abc.jpg was one of the 5 selected files.
does that make sense?
thanks
(PS... I wish the email notification would work on the forum. messages i never get notified about - not even in spam)
Re: Need help running code to run on many selected files
Posted: 08 Mar 2018 13:31
by Squashman
I don't see anything technically wrong with the code you are trying to use. It will fail if you try and drag and drop too many files onto the batch file because there is a command line limit of 8191 characters.
Re: Need help running code to run on many selected files
Posted: 08 Mar 2018 16:33
by penpen
If
adding a menu item to the your shell menu is an option for you, then this ".reg"-file might help you (right-click & "merge" this once):
Code: Select all
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\My Item\Command]
@="cmd /E:ON /F:ON /C \"@((for %%s in (\"%1\") do @echo call your.bat %%s or use foo\convert %%s -strip %%s) & pause)\""
Note: The above only echoes some possibilities, you might replace the echo command with your above one.
penpen
Re: Need help running code to run on many selected files
Posted: 09 Mar 2018 06:26
by OM3
guys thanks for the replies.
yes... code seems to work
but in output i see:
Code: Select all
C:\Users\me\images>convert "C:\Users\omars\images\image8.jpg" -strip "C:\Users\me\images\image8.jpg"
C:\Users\me\images>shift
C:\Users\me\images>if not "" == "" goto :loop
surely i shouldnt see that? just wondering if loop even happens?
penpen wrote: ↑08 Mar 2018 16:33
If
adding a menu item to the your shell menu is an option for you, then this ".reg"-file might help you (right-click & "merge" this once):
Code: Select all
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\My Item\Command]
@="cmd /E:ON /F:ON /C \"@((for %%s in (\"%1\") do @echo call your.bat %%s or use foo\convert %%s -strip %%s) & pause)\""
Note: The above only echoes some possibilities, you might replace the echo command with your above one.
penpen
adding item to shell menu?
never seen it before... how would i get? that would be awesome!
assume you are saying i can add to right click menu?
Re: Need help running code to run on many selected files
Posted: 09 Mar 2018 07:59
by penpen
OM3 wrote: ↑09 Mar 2018 06:26
adding item to shell menu?
never seen it before... how would i get? that would be awesome!
assume you are saying i can add to right click menu?
Yes, you are assuming right, the shell menue is the right click menue.
You just have to save my above code as a ".reg"-file, for example: "My Item.reg". Then right click "My Item.reg" and select "merge" from the menue (on most system it might suffice if you double-click this file). Assuming you have enough rights on your PC you should get a warning, that chaning the registry might harm your pc (or similar), and finally you should get a message confirming the changes are successfully added to your registry.
From now on you should have an item named "My Item" in your shell menue.
Alternatively you might create this shell menue manually:
Just execute "regedit.exe" (with enough rights), then goto "HKEY_CLASSES_ROOT\*\shell" and create a key with any valid name you wish (no function key, no backslash, ... ) - that is the name of the shell menue item you create.
Then create a subkey (within the new key) named "Command" and doubleclick the "(Default)" REG_SZ type property and type in the file you wish to execute (with command line arguments). Make sure the file is listed in your PATH variable, or use the absolute path of that executable file.
penpen
Re: Need help running code to run on many selected files
Posted: 09 Mar 2018 12:34
by OM3
cool! sounds so awesome.
if i had this in my file is this correct:
[HKEY_CLASSES_ROOT\*\shell\My Item\Command]
@="cmd /E:ON /F:ON /C \"@((for %%s in (\"%1\") do convert %%s -strip %%s) & pause)\""
If OK... how can I remove?
Also... how can I create parents - when selected, another set of menu options appear
Thanks
ALSO... i'm still not sure about the other part...
Code: Select all
C:\Users\me\images>convert "C:\Users\omars\images\image8.jpg" -strip "C:\Users\me\images\image8.jpg"
C:\Users\me\images>shift
C:\Users\me\images>if not "" == "" goto :loop
surely i shouldnt see that? just wondering if loop even happens?
thanks
Re: Need help running code to run on many selected files
Posted: 09 Mar 2018 18:01
by ShadowThief
OM3 wrote: ↑09 Mar 2018 12:34
If OK... how can I remove?
Just delete the registry key if you want to get rid of it.
OM3 wrote: ↑09 Mar 2018 12:34
Also... how can I create parents - when selected, another set of menu options appear
https://superuser.com/questions/723530/ ... s-explorer
OM3 wrote: ↑09 Mar 2018 12:34
ALSO... i'm still not sure about the other part...
Code: Select all
C:\Users\me\images>convert "C:\Users\omars\images\image8.jpg" -strip "C:\Users\me\images\image8.jpg"
C:\Users\me\images>shift
C:\Users\me\images>if not "" == "" goto :loop
surely i shouldnt see that? just wondering if loop even happens?
thanks
You're seeing it because @echo off was commented out for some reason, and you're seeing one file get processed and then an empty comparison presumably because you only passed one file to the script.