Frage

I've made a little script so I can select some files in Explorer (on Windows XP), right click, and Sendto. The script works fine for up to 20 files, but fails when 21 or more files are selected. Why & how can I fix this?

:Loop
If "%~dpn1"=="" Goto :EOF
convert "%~dpn1.jpg" "%~dpn1_dvr_hires.tif"
convert "%~dpn1.jpg" -scale 150 -density 72 "%~dpn1_dvr_hires_renamed.jpg"
Shift 
Goto Loop

When I drag & drop or use the sendto menu: <20 files, and the command runs fine as expected, but >20 and I get a "Windows cannot access the specified device, path, or file. You may not have the appropriate permission to access the item." I have checked & changed the permissions, the permissions do not seem to be the problem.

War es hilfreich?

Lösung

Send To uses the same mechanism as drag and drop. A command line is built incorporating the full path to each file name as arguments. There is a maximum line length of 8191 bytes. I suppose it is possible that you are reaching that limit with only 21 files, but it is highly unlikely.

The more likely scenario is you may be running into file names that contain & and/or ^ characters. There is a bug with "drag and drop" / "Send To" that fails to properly quote file names containing & or ^. It is frustrating, because names containing space are properly quoted.

See “Droplet” batch script - filenames containing ampersands for more information and a possible solution.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top