Jump to content

Raffie77

Member
  • Posts

    21
  • Joined

  • Last visited

Posts posted by Raffie77

  1. Let me explain: I rename a lot of photos based on information on the internet.

    I copy words like "bird", "trees", "fly", etc., which are then on my clipboard.

    I have a workflow that renames files using exiftool.

    In that workflow, I can also add names myself.

    At that point, I would like to have access to my clipboard, so that I can add different words from the clipboard to my workflow.

    But if I activate the clipboard, my workflow is gone (Workflow no longer has focus).

    The same goes for if I am in the workflow and I want to copy a difficult word that is on a website, then I cannot do that because the workflow is gone again.

     

    Is there a solution for this?

  2. 5 minutes ago, vitor said:

    Again, try ${clip} directly, like the example I gave you. -geotag expects a file path (check man exiftool). You’re conflating bash variables with user parameters, which are meant to be used for tagging (again, manual).

     

    huh?😣 that works

    ok now I am confused, it's great that it works now thanks @vitor.

    If you take a look at the script in my first post

    you see a case k_basRenExtFile and k_basRenCurFile

    those work. and I thought I used the same technique 

     

    I'm gonna study this script for a while

    thank you both for your time, I appreciate that very much

  3. 2 minutes ago, vitor said:

    Try ${exiftool} -overwrite_original -geotag="${clip}" "${files[@]}"

     

    ok this is a exiftool thing lets say if I want to see the model of  a image, I type:

     ${exiftool} $model photo.jpg

    if I type:

    ${exiftool} -overwrite_original -geotag="${clip}" "${files[@]}"

    exiftool thinks I want to see the property of ${clip} and that doesn't exist

    that's where the -userparam kicks in

    -userparam tracklog="$clip"

    it means create a property tracklog with the value of $clip

    and $clip means clipboard see the screenshot

     

    and when I echo $clip I see this result in the debug:

    Clip = /Users/ralphschipper/Downloads/2020-05-09 17_15_25.gpx

    so the clip var is set correctly

     

    I hope this makes sense

  4. 4 minutes ago, vitor said:

    What’s $tracklog supposed to be? You’re not setting the variable anywhere, so the script is reading if for what it is: nothing.

    oh sorry I forgot to say:

    var tracklog is located in a var in alfred see screenshot385775140_Schermafbeelding2020-05-09om20_53_22.png.9f3b528ad259c45c01f2c64b79330f52.png

     

    when I add this line in te script:

    ${exiftool} -overwrite_original -userparam tracklog="$clip" -geotag=$tracklog "${files[@]}"
    echo "Clip = $clip"

    The debug result =

    Clip = /Users/ralphschipper/Downloads/2020-05-09 17_15_25.gpx

    I have the workflow here

     

     

  5. It's very bizar I have this script in Alfred:

    #######################################
    #Exiftool utility for Alfred workflow #
    #######################################
    set -x
    IFS=$'\t' read -ra files <<< "${file_list}"
    command=${command} #Located at the arg block after the List Filter in the workflow
    sourceFiles="/Users/$USER/temp/"
    
    case $command in
    	basRen) #Basic rename
    		${exiftool} -d "%Y-%m-%d %H,%M,%S%%-c" '-filename<${DateTimeOriginal} $Make-$Model.%e' "${files[@]}"
    		;;
    	k_basRenExtFile) #Basic rename with an extra added name from a query
    		${exiftool} -userparam extName="$keyword" -d "%Y-%m-%d %H,%M,%S%%-c" '-filename<${DateTimeOriginal} $Make-$Model $extName.%e' "${files[@]}"
    		;;
    	k_basRenCurFile) #Rename the current file(s) with a extra query e.g. test.jpg > test foo.jpg
    		${exiftool} -userparam extName="$keyword" -d "%%f" '-filename<${DateTimeOriginal} $extName.%e' "${files[@]}"
    		;;
    	datMap) #Move selected files to a subfolder YYYY-mm created from DateTimeOriginal exif tag, if the folder doesn't exsist create it creates that folder
    		${exiftool} -d "%%d/%Y-%m/%%f.%%e" '-filename<DateTimeOriginal' "${files[@]}"
    		;;
    	geoTag) #Select a single file and Show it in Apple maps or Google maps. In the main vars section choose by map_provider 'Apple' or 'Google'
    		[[ "${map_provider}" == 'Google' ]] && map_url='https://www.google.com/maps?t=k&q=' || map_url='http://maps.apple.com/?q='
    		coordinates="$(${exiftool} -printFormat '$gpslatitude, $gpslongitude' --printConv "${files}")"
    		open "${map_url}${coordinates}"
    		;;
    	tracklog) #Find the tracklog in finder > double tab cmd and choose 'copy path to clipboard' and run this script
    		${exiftool} -overwrite_original -userparam tracklog="$clip" -geotag=$tracklog "${files[@]}"
    		;;
    	photos2kml) #Select photos and check if it has GPS data in the Exif, if so that create a KML file and open it in Google Earth
    		${exiftool} -p "${sourceFiles}gpx.fmt" -r "${files[@]}" > "${sourceFiles}photos.kml"
    		open "${sourceFiles}"
    		open "${sourceFiles}photos.kml"
    		;;
    	dateFields) #Show alle date fields in CSV format from selected files
    		${exiftool} -csv -time:all -s  "${files[@]}" > "${sourceFiles}exiftool_output.csv"
    		open "${sourceFiles}exiftool_output.csv" 
    		;;
    	megapixels) #Show magapixels in CSV format from selected files
    		${exiftool} -csv -megapixels  "${files[@]}" > "${sourceFiles}exiftool_output.csv"
    		open "${sourceFiles}exiftool_output.csv" 
    		;;
    	basDetails) #Show basic information in CSV format from selected files, you can edit the fiels in the format file
    		${exiftool} -c %.7f -api filter='$_ = qq{"$_"} if s/"/""/g or /(^\s+|\s+$)/ or /[,\n\r]/' -f -p "${sourceFiles}csv.fmt" "${files[@]}" > "${sourceFiles}exiftool_output.csv"
    		open "${sourceFiles}exiftool_output.csv" 
    		;;
    	*)
    		exit ;;
    esac
    set +x

    All the case parts works perfect, except case tracklog the part that says:

    -geotag=$tracklog

    when I run this script I see this result in the debug screen:

    case $command in
    + /usr/local/bin/exiftool -overwrite_original -userparam 'tracklog=/Users/ralphschipper/Downloads/2020-05-09 17_15_25.gpx' -geotag= '/Volumes/Ext 1TB/Google Drive/temp/test1/MapA/P1110188.JPG'

    if you look at the pard -geotag= you see its blank the next part is the photo that is selected tru a File Action 

    As I said all the rest of the cases works great except tis part.

     

    Can anyone see what I'm doing wrong here?

  6. vitor:

    thank you very very very much🙌

    it works!

    I nerver heard of/used 

    IFS=$'\t'

    so i read into that, now I understand

    I tested this and it still didn't work, the issue is, in this line:

    ${exiftool} -d "%Y-%m-%d %H,%M,%S%%-c" '-filename<${DateTimeOriginal} $Make-$Model "${1}".%e' "${files[@]}"

    The "${1}" in this line doesn't work, if you take a look at $Make-$Model that means that Exiftool gets the value of the make and the model.

    "${1}" is not a Exiftool value, but Exiftool is reading this as a Exiftool value and that value doesn't exist.

     

    so for people who wants to know how to fix this?

    this is the working code:

    IFS=$'\t' read -ra files <<< "${file_list}"
    
    ${exiftool} -userparam extName="${1}" -d "%Y-%m-%d %H,%M,%S%%-c" '-filename<${DateTimeOriginal} $Make-$Model $extName.%e' "${files[@]}"

    Exiftool has a option -userparam here you can create a user parameter in my case called extName (extra name)  and I used that later on after the $Make-$Model

     

    I have the working version here 

  7. I also add a keyword in alfred in cas I want to add an extra name like "flower" of "tree" etc.

    in the script i have this:

    ${exiftool} -d "%Y-%m-%d %H,%M,%S%%-c" '-filename<${DateTimeOriginal} $Make-$Model "${keyname}".%e' "${files}"

    If I enable the debug mode I get this message:

    Quote

    Warning: [minor] Tag 'keyname' not defined - /Volumes/Ext 1TB/Google Drive/temp/test 1/MapA/243.jpg

     

    The "$keyname" is a var that I created in Alfred see screenshot, the first var is the "$files" and the second var = "$keyname"

    in te script I used "$keyname" with the purpose to enter the text that I typ in Alfred, but Exiftool thinks that "$keyname" is a Exiftool code and that's not the case hence the error

    well single and double quotes and escaping are not my strong suite. 

    Do I need to escape something here or split up the quotes ore something like that?

     

    btw this code below works great (without the $keyname):

    ${exiftool} -d "%Y-%m-%d %H,%M,%S%%-c" '-filename<${DateTimeOriginal} $Make-$Model.%e' "${files}"

     

     

    Schermafbeelding 2020-05-02 om 12.11.07.png

  8. 1 hour ago, vitor said:

     

    ooohhh shoot, you're right

    I tweaked the script a bit and it almost works

    the link that you are refering to is ment for one single file.

    when I select multiple files in my new script, only one gets renamed

    how can I make it happen that he renames all the files I select and not just one?

    Do I need to convert a array or something?

  9. 2 minutes ago, deanishe said:

    What do you mean by this?

    i want to create a script for exiftool

    so I want to select those files that I want to rename and copy this to the clipboard:

    exiftool -d "%Y-%m-%d %H,%M,%S%%-c" '-filename<${DateTimeOriginal} $Make-$Model.%e' {multiple files that are decent escaped}

     

    6 minutes ago, deanishe said:

    You can write one easily enough. Python 2 has pipes.quote() (shlex.quote() in Python 3) to escape a string in the way a shell expects. I’m sure other languages have the same.

    ok I never worked with python i'll look into that

    I see that I can run a Pythons script in Alfred workflow

     

    Thanks

  10. Hi,

    I'm trying to create a workflow that can copy paths for later use.

    Frist I create a new workflow and add a file action to it that accepts multiple lines

    then I enter a copy to clipboard module that says {query}

    I run this script by selecting 2 files and double tap the command key and choose my test script

    and I paste it textedit

    the result:

    /temp/test 1/MapA/test (2).JPG
    /temp/test 1/MapA/test (1).JPG

     

    the thing is when I drag the 2 files to a terminal window I get this:

    /test\ 1/MapA/test\ \(1\).JPG /test\ 1/MapA/test\ \(2\).JPG 

    filenames are separated by a space and the filenames are escaped

     

    is there a script that can do this to?

    so when I select files it copy's the full pathnames escaped and separated by a space?

  11. Oh and btw, I prefer that google opens the photo in satelite mode

    to fix this I edit this line in the bash script part of your workflow:

    Quote

     

    and made it:

    Quote

     

    now it opens the photo in satelite mode.

    It took me a while to figure that one out 

     

     

  12. Hi people,

     

    this is not a workflow, it's a snippet that shows you the location of the photo in google maps is satelite mode.

     

    this is the snippet: 

    Quote

    open "http://maps.google.com?t=k&q=loc:$(exiftool -ee -p '$gpslatitude, $gpslongitude' -c "%d°%d'%.2f"\" {cursor} 2> /dev/null | sed -e "s/ //g")"

     

    how to use it:

    • open terminal
    • activate this snippet while in Terminal
    • open the folder where your photo is located in finder
    • drag the photo that contains gps data to your terminal
    • activate  the terminal window and press enter

     

    It took me some time to figure out how to open the photo in Google maps in satelite mode.

    When you activate this snippet, note the location of the cursor, it's not at the end (for a reason 🙂 )

     

    Oh and btw, you need to install exiftool from phil Harvey: Exiftool to use this snippet

×
×
  • Create New...