No such file or directory

Started by stevewilley, August 06, 2022, 06:16:06 AM

Previous topic - Next topic

stevewilley

Thanks in advance for your help - apologies if my knowledge appears pretty basic on this, I do seem to have hit a wall.

I'm running the mac version and I ran a test and managed to get one test file to change the exif data using instructions I found in the documentation. I then tried to add the overwrite command so that it didn't duplicate files and it then returned a command prompt rather than just running so I figured I must have done something wrong. I then tried to double back and go back to my original command and it now returns a 'No such file or directory'. I assumed this was human error with typos but when I enter that directory into the terminal, it confirms that a directory does exist. As per some previous threads, I have attempted to uninstall and reinstall but unfortunately the same issue persists.I have read as many threads as I can find but can't seem to solve the issue - any advice would be greatly received.

The overall picture is that I'm currently migrating all my photos from Dropbox to Googledrive. All images have the dates in the title so I am attempting to rewrite the EXIF data based on this. There are lots of files so I'm hoping to direct it at one folder and it run on all the files and overwrite them, rather than creating duplicates.

The current command I am running is this:

exiftool '-AllDates<filename' DIR

Any thoughts gratefully received!


greybeard

First backup all your files - that way you will be able to recover from errors.

Are you trying to change the dates in the EXIF to the date in the name of the file?

Check that your files still exist in that folder (and there is nothing else in the folder)

Can you give us some examples of the names of your files?

If the filenames were all something like "2022_06_06.jpg" and you wanted to change the dates to 2022_06_06
then the command would be something like:

exiftool '-AllDates<${filename;s/.*(\d{4}_\d{2}_\d{2}).*/$1/} 12:00:00' -overwrite_original DIR

(Don't use DIR - but use the name of your directory or go into the directory and change DIR to .)

Alan Clifford

If it didn't run and gave a command prompt then you probably had a mismatched quote. Did you cut-and-paste your command line so we could check that?  If so, as greybeard said, you shouldn't type DIR but the actual directory name.  The current directory is a single .

stevewilley

Thanks both so much for your replies and sorry for the delay. Happy to provide more details and hopefully it'll make it all a bit clearer.

The date and time is currently in the name of the image files. The creation date of the file however is a few days ago as when I copied them to google drive, it seemed to create a new file. I have also inspected the EXIF file of a few and the DateTimeOriginal field is blank. This means that when uploaded to google photos, the photos will be on the wrong date so I am trying to use the date in the file name to rewrite AllDates. I think google photos look at the DateTimeOriginal field.

An example file name is: 2012-03-04 16.51.58.jpg.

I'm currently running the script on a test folder and will make sure to back up all photos before. They're currently on my google drive so I'll download them to a hard drive first.

Where I've written DIR, I am replacing the actual directory. My current directory looks like this: /Users/stevewilley/Desktop/images/ Thank you for checking this though, appreciate this would be an issue for finding the files.

The full script I was trying to run looks like this: exiftool '-AllDates<filename' /Users/stevewilley/Desktop/images/

Thank you for the new script and I think I'm understanding it correctly in terms of grabbing the different elements. One thing I did wonder was whether the additional number (16.51.58 in the example above of the image file name) was confusing it? Given the name of the example file I've provided do I need to do anything different with the time bit of the code?

Hopefully that all makes sense, really appreciate your help.
Steve


greybeard

#4
As I understand it the problem with your method is that the filename includes ".jpg" - its not just the date.

To extend my original example to pick up your complete file format:

exiftool '-AllDates<${filename;s/.*(\d{4}_\d{2}_\d{2} \d{2}.\d{2}.\d{2}).*/$1/}' -overwrite_original /Users/stevewilley/Desktop/images
This assumes all the files are in exactly the same format

A simpler version would be:

exiftool '-AllDates<${filename;s/(.*)\.jpg$/$1/}' -overwrite_original /Users/stevewilley/Desktop/images

stevewilley

Wow, that's awesome, thank you so much - this works perfectly! I'll make sure to back everything up then run the script!

I don't think I would have got to the bottom of the fact that the jpg aspect was the issue so this is a huge help, thank you.

It would be great if I could just query a couple of other scenarios.

I have some .jpeg files - I'm assuming I can change the '.jpg' aspect of the command to apply it to these files?

I also have some .mov and .mp4. Is overwriting the creation date the same with movie files or do I need to treat them completely differently? I was going to try changing .jpg to .mov or .mp4 and see what happens but I think I read somewhere that movie files have slightly different parameters?

Finally, I have a few photos taken from an SLR camera with a naming convention of IMG_0001.jpg. If I wanted to just write in a set date that I specify from a command, what would be the command for this?

Sorry to ask more questions but I think with all these solutions, I'll be set up for future tasks. Once again, huge thanks to everyone that has helped me here - it's provided the solution to over 20000 photos!

greybeard

Quote from: stevewilley on August 08, 2022, 03:03:18 AMI have some .jpeg files - I'm assuming I can change the '.jpg' aspect of the command to apply it to these files?

If you change the command to this it will match either jpg or jpeg:

exiftool '-AllDates<${filename;s/(.*)\.jp[e]?g$/$1/}' -overwrite_original /Users/stevewilley/Desktop/images
You can also choose to have the command apply to either jpg or jpeg files by using -ext jpg and/or -ext jpeg - for example this applies to jpg and jpeg files but would ignore files with other extensions in the directory:

exiftool '-AllDates<${filename;s/(.*)\.jp[e]?g$/$1/}' -overwrite_original -ext jpg -ext jpeg /Users/stevewilley/Desktop/images
QuoteI also have some .mov and .mp4. Is overwriting the creation date the same with movie files or do I need to treat them completely differently? I was going to try changing .jpg to .mov or .mp4 and see what happens but I think I read somewhere that movie files have slightly different parameters?

Not sure about movie files - someone else can help here

QuoteFinally, I have a few photos taken from an SLR camera with a naming convention of IMG_0001.jpg. If I wanted to just write in a set date that I specify from a command, what would be the command for this?


exiftool -AllDates="2015:12:04 15:11:58" DIR

Phil Harvey

Quote from: greybeard on August 08, 2022, 05:07:30 AM
QuoteI also have some .mov and .mp4. Is overwriting the creation date the same with movie files or do I need to treat them completely differently? I was going to try changing .jpg to .mov or .mp4 and see what happens but I think I read somewhere that movie files have slightly different parameters?

Not sure about movie files - someone else can help here

There are a number of other date/time fields in movie files.  You might try something like this for movies:

exiftool '-time:all<${filename;s/(.*)\.[^.]+$/$1/}' -wm w -ext mov -ext mp4 DIR
The "-wm w" is necessary to prevent creating new date/time tags since writing Time:All would otherwise create all possible date/time tags.

- 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 ($).

wywh

Quote from: Phil Harvey on August 08, 2022, 08:15:40 AMexiftool '-time:all<${filename;s/(.*)\.[^.]+$/$1/}' -wm w -ext mov -ext mp4 DIR

Oh great! I have been using the following long command in movies (.mp4, .m4v, .mov) to set all QuickTime tags (including the not so important Track and Media dates), Keys (that iOS devices use and Photos.app prioritises) and file dates neatly the same...

exiftool -api QuickTimeUTC=1 '-AllDates<FileName' '-Track*Date<FileName' '-Media*Date<FileName' '-Keys:CreationDate<FileName' -execute '-FileCreateDate<FileName' '-FileModifyDate<FileName' -common_args -m -P -overwrite_original_in_place -wm w .

exiftool -a -G1 -s -api QuickTimeUTC=1 -time:all -api RequestAll=2 2022-0612-1923-17.mov
[System]        FileModifyDate                  : 2022:06:12 19:23:17+03:00
[MacOS]         FileCreateDate                  : 2022:06:12 19:23:17+03:00
[QuickTime]     CreateDate                      : 2022:06:12 19:23:17+03:00
[QuickTime]     ModifyDate                      : 2022:06:12 19:23:17+03:00
[Track1]        TrackCreateDate                 : 2022:06:12 19:23:17+03:00
[Track1]        TrackModifyDate                 : 2022:06:12 19:23:17+03:00
[Track1]        MediaCreateDate                 : 2022:06:12 19:23:17+03:00
[Track1]        MediaModifyDate                 : 2022:06:12 19:23:17+03:00
[Track2]        TrackCreateDate                 : 2022:06:12 19:23:17+03:00
[Track2]        TrackModifyDate                 : 2022:06:12 19:23:17+03:00
[Track2]        MediaCreateDate                 : 2022:06:12 19:23:17+03:00
[Track2]        MediaModifyDate                 : 2022:06:12 19:23:17+03:00
[Track3]        TrackCreateDate                 : 2022:06:12 19:23:17+03:00
[Track3]        TrackModifyDate                 : 2022:06:12 19:23:17+03:00
[Track3]        MediaCreateDate                 : 2022:06:12 19:23:17+03:00
[Track3]        MediaModifyDate                 : 2022:06:12 19:23:17+03:00
[Track4]        TrackCreateDate                 : 2022:06:12 19:23:17+03:00
[Track4]        TrackModifyDate                 : 2022:06:12 19:23:17+03:00
[Track4]        MediaCreateDate                 : 2022:06:12 19:23:17+03:00
[Track4]        MediaModifyDate                 : 2022:06:12 19:23:17+03:00
[Track5]        TrackCreateDate                 : 2022:06:12 19:23:17+03:00
[Track5]        TrackModifyDate                 : 2022:06:12 19:23:17+03:00
[Track5]        MediaCreateDate                 : 2022:06:12 19:23:17+03:00
[Track5]        MediaModifyDate                 : 2022:06:12 19:23:17+03:00
[Keys]          CreationDate                    : 2022:06:12 19:23:17+03:00

...but the following simple command seems to do just the same (I have to test whether Xcode Command Line Tools install is still needed -- it can be ignored but then the FileCreateDate might move only backwards in time):

exiftool -m -P -overwrite_original_in_place -wm w -api QuickTimeUTC=1 '-time:all<$FileName' .
It seems to work even though I clipped off the last characters that I don't yet fully understand from {FileName;s/(.*)\.[^.]+$/$1/}. Do I need them with files named as YYYY-MMDD-hhmm-ss.* ?

Another newbie question about the '$' character use. I also tried to simplify it even more but this does not work...

exiftool -m -P -overwrite_original_in_place -wm w -api QuickTimeUTC=1 '-time:all<FileName' .
Warning: No writable tags set from ./2022-0612-1923-17.m4v
    1 directories scanned
    0 image files updated
    1 image files unchanged

...is the '$' needed because we are copying to a different family group with 'time:all' option?

The -ext option does not seem to be needed with .mp4, .m4v and .mov at least if there are no other file types in that folder.

- Matti



greybeard

Quote from: wywh on August 08, 2022, 10:12:58 AMAnother newbie question about the '$' character use. I also tried to simplify it even more but this does not work...

exiftool -m -P -overwrite_original_in_place -wm w -api QuickTimeUTC=1 '-time:all<FileName' .
Warning: No writable tags set from ./2022-0612-1923-17.m4v
    1 directories scanned
    0 image files updated
    1 image files unchanged

...is the '$' needed because we are copying to a different family group with 'time:all' option?

No - see the discussion about the original post - your filename is not a valid date format - your filename has the date plus the .m4v extension

Phil Harvey

I used the regex to remove the file extension because I copied and pasted from greybeard's command and he was removing the \.jpe?g, but this shouldn't be necessary when writing date/time values because ExifTool is smart enough to ignore it (with the exception of date/time tags with unformatted values which you probably aren't writing anyway).

About the necessity of the "$" sign:  The last paragraph in the -tagsFromFile documentation explains this:

            Finally, the behaviour is different when a destination tag or
            group of "All" is used.  When copying directly, a destination
            group and/or tag name of "All" writes to the same family 1 group
            and/or tag name as the source.  But when interpolated in a string,
            the identity of the source tags are lost and the value is written
            to all possible groups/tags.  For example, the string form must be
            used in the following command since the intent is to set the value
            of all existing date/time tags from "CreateDate":

                exiftool '-time:all<$createdate' -wm w FILE


- 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 ($).

greybeard

Quote from: Phil Harvey on August 08, 2022, 03:03:03 PMI used the regex to remove the file extension because I copied and pasted from greybeard's command and he was removing the \.jpe?g, but this shouldn't be necessary when writing date/time values because ExifTool is smart enough to ignore it (with the exception of date/time tags with unformatted values which you probably aren't writing anyway).

Thanks - it seems I gave an overcomplicated solution - I hadn't realised exiftool was smart enough to extract the date from the filename and ignore the extension.

Apologies to the OP

stevewilley

Thank you for all your help with the solutions, I have now successfully processed all the photo files and they have worked perfectly.

When trying to process the movie files, it located/processed the files and then created a new file with the 'original' title in the name. I understand that to overwrite it, I would need to include the command but I just wanted to test it first. Oddly, even though the duplicate file was the exact same size of the original movie file, the file couldn't be opened by any programs. While they did have the .mov extension, the icon was blank and wouldn't open. Any thoughts on why this might be?

There are far fewer movie files so I have been gradually manually editing the exif data but if there were any thoughts, I'd be keen to understand what isn't quite working correctly.

Thanks again for your help.
Steve

Phil Harvey

Are you saying that the MOV file can't be opened after it was edited by ExifTool?  If so, upload the original (or email to philharvey66 at gmail.com) and post the exact command you used and I'll take a look.

- 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 ($).

greybeard

or do you mean that the .mov_original files don't have an icon and won't open?

that is expected - these are the original files renamed so that you can restore them if needed.