Jump to content

markp

Member
  • Posts

    5
  • Joined

  • Last visited

Everything posted by markp

  1. No go on the word problem -- now it doesn't create any directories anymore! I'll experiment with the move/copy features.
  2. Yeah, no joy, unfortunately! I've made these changes but a query of "[keyword] client - project word word word" still only creates a directory called "client - project" I've also got a file called project.pdf in the downloads directory and it's not being copied over. Oh well -- I'll keep playing with it. #!/bin/sh # Check to make sure that the syntax is followed. if [[ ! "{query}" =~ " - " ]]; then echo "Invalid entry. Please use 'Client - Project' syntax." exit fi # Set the base directory for all of the projects. # If you don't want it in the home directory, then # replace $HOME with the __FULL__ path to the base # directory. basedir="/Users/redacted/Dropbox/CURRENT JOBS/NEW/" downloads="/Users/redacted/Desktop/" # IFS is the internal field separator. If you want # something else, then change it. For now it's: # " - " while IFS=' - ' read -ra string; do # since there are only two arguments in this array, # we don't need to loop through it. client="${string[0]}" project="${string[1]}" done <<< "{query}" client=`echo $client | tr '[:lower:]' '[:upper:]'` project=`echo $project | tr '[:lower:]' '[:upper:]'` # Make the directories if [ ! -d "$basedir/$client - $project" ]; then mkdir "$basedir/$client - $project" fi #Scan the downloads folder for files files=`find "$downloads" -iname '*"$client"*' -o -iname '*"$project"*' \ -maxdepth 0 -type f` if [[ "${#files[@]}" -gt 0 ]]; then for file in "${files[@]}" do cp "$file" "$basedir/$client - $project" done fi echo "Project created."
  3. Thanks Shawn! Still two things. (I REALLY appreciate all your help on this.) 1. If I enter "[keyword] client - project" where project has one word, everything works fine. But if I enter "[keyword] client - project name" where project name has two words, the script will return the error "Invalid entry. Please use 'Client - Project' syntax." Is that because I'm using the "-"? My understanding was that the " - " in my query was just a delimiter to differentiate the client string from the project name string? 2. It doesn't look like the copy functionality is working at all. Using the code you supplied, I got the error "Code 0: /bin/bash: line 38: copy: command not found", so I changed copy to cp, and now it says "Code 0: cp: fts_open: No such file or directory" when there definitely is? Any ideas? (And again, THANK YOU.)
  4. Hey Shawn - Thanks a ton for your help. I'm still learning, so any answers you might be able to provide to the following questions would be amazing: 1. What if I'd like for my argument to be Client - Project where either client or project could be multiple words? 2. Is there a way to force the directory name to be created in all caps? 3. I've included my amended bash script is below. The debugger is still yielding the following error whenever I use it, though [ERROR: alfred.workflow.action.script] Code 2: /bin/bash: -c: line 32: unexpected EOF while looking for matching ``' /bin/bash: -c: line 41: syntax error: unexpected end of file Any tips? #!/bin/sh # Check to make sure that the syntax is followed. if [[ "{query}" =~ " - " ]]; then echo "Invalid entry. Please use 'Client - Project' syntax." exit fi # Set the base directory for all of the projects. # If you don't want it in the home directory, then # replace $HOME with the __FULL__ path to the base # directory. basedir="/Users/redacted/Dropbox/New Jobs/" downloads="/Users/redeacted/Downloads/" # IFS is the internal field separator. If you want # something else, then change it. For now it's: # " - " while IFS=' - ' read -ra string; do # since there are only two arguments in this array, # we don't need to loop through it. client="${string[0]}" project="${string[1]}" done <<< "{query}" # Make the directories if [ ! -d "$basedir/$client - $project" ]; then mkdir "$basedir/$client - $project" fi #Scan the downloads folder for files files=`find "$downloads" -iname '*"$client"*' -o -iname '*"$project"*' \ -maxdepth 0 -type f for file in "${files[@]}" do copy "$file" "$basedir/$client - $project" done echo "Project created."
  5. Hi all -- I'm brand new to Alfred and this community, so apologies if some of these questions have already been answered. I work on a lot of new projects and manage a LOT of files. Here, in a nutshell, is something I'd love to be able to do programmatically: * Initiate a workflow with the naming convention "Client - Project" * Have Alfred create a folder with that name in a set directory * Have Alfred scan a separate directory of recent downloads for the "client" and/or "project" keywords and then move all matching files to the directory created above Is this the kind of thing you can do with Alfred? And if so, can someone point me to a few appropriate links? Thanking you!
×
×
  • Create New...