New file name not allowed that contains ":" as in "C:/Users"

Started by slim, December 20, 2023, 05:22:07 PM

Previous topic - Next topic

slim

I am trying to rename a batch of photos based on their camera ID and datetime. When I try to rename the photos, pulling that info from their metadata, I get this error: "Warning: New file name not allowed in Windows (contains ':') - C:/Users/user/Documents/test_images/135/DCIM/100RECNX/RCNX0526.JPG." I'm not sure how to get around this, as the colon is in the name of the drive.

StarGeek

Can you post the relevant part of your code or the actual command that gets executed?

Odds are that you actually have the drive name twice.  So exiftool ends up trying to write something like C:/Users/C:/Users/user/Documents/test_images/135/DCIM/100RECNX/RCNX0526.JPG
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

BlackMagic

If you're typing it exactly as you have here, the problem is likely that you're using slashes ( / ) rather than backslashes ( \ ). Windows needs backslashes for directory paths, otherwise it probably sees that as a big text string for a single filename rather than a full path, and that's why it's not liking the colon.

The path should look like this:
C:\Users\user\Documents\test_images\135\DCIM\100RECNX\RCNX0526.JPG

Phil Harvey

You can use either forward or backward slashes in ExifTool commands on Windows.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

Giving it further thought, I think the answer will lie with the %d directory variable.  If you use a rename which looks like this
exiftool "-filename<C:\path\to\NewDir\%d$DateTimeOriginal.%e" -d "%Y-%m-%d_%H.%M.%S" C:\Path\to\source\

What happens is you start with a target directory of
C:\path\to\NewDir\
but the %d adds the directory for the source files, in this case
C:\Path\to\source\
so you end up with
C:\path\to\NewDir\C:\Path\to\source\
which throws the above error.

Note that if you CD to C:\Path\to\source\ first and use a dot for the current directory, you won't have this error, as the combined directory is
C:\path\to\NewDir\.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

BlackMagic

Quote from: Phil Harvey on December 27, 2023, 04:14:27 PMYou can use either forward or backward slashes in ExifTool commands on Windows.

- Phil

Thanks, that's helpful!