I have i.e. a folder full with alias from everywhere on my system. Now I want to give exactly this files as the originals to an extern hard drive or what else.
Is there a way to simply take these alias and copy their originals into a second folder?
aliascopy/pastefilefinder
I have i.e. a folder full with alias from everywhere on my system. Now I want to give exactly this files as the originals to an extern hard drive or what else.
Is there a way to simply take these alias and copy their originals into a second folder?
If you simply want to pass a file name to the Spotlight action
The pass the file name from an action to a set variable Action
THIS IS AN UPDATE
Using Automator actions and Applescript to store properties for later retrieval:
The idea here is the first action writes out a applescript file to the documents folder.
The script will be used to store information we get along the way and then retrieve it later on in the final Applescript action.
We do this because we need to pass the final script multiple bits of information. Which we cannot do with the normal variables in Automator.
The Actions.
The script.
set script_text to MakeScript()
my RunMaker(script_text)
on RunMaker(script_text)
set file_path to (path to documents folder as Unicode text) & "MyProperties.scpt"
set file_path to POSIX path of file_path as string
store script script_text in file_path with replacing
end RunMaker
on MakeScript()
script
property theBrokenAliasFolderPath : ""
property broken_alias_file_Paths : {}
property theOriginalFolderPath : ""
property Original_file_Paths : {}
property SearchfileNames : {}
end script
end MakeScript
2, Ask for Finder Items: This is for the Broken Alias folder.
3,Run Applescript:
( The write outs are done by the Action Applescript loading the storage file script. This will be a version of sorts. It will then change properties in its version and re-write the file out again replacing the old one)
--WRITE OUT BROKEN ALIAS FOLDER PATH
on run {input, parameters}
set file_path to (path to documents folder as Unicode text) & "MyProperties.scpt" as alias
set script_text to load script file_path
set theBrokenAliasFolderPath of script_text to (POSIX path of (item 1 of input))
my RunMaker(script_text)
return input
end run
on RunMaker(script_text)
set file_path to (path to documents folder as Unicode text) & "MyProperties.scpt"
set file_path to POSIX path of file_path as string
store script script_text in file_path with replacing
end RunMaker
4,Get Folder contents:
5, Filter Finder Items:
All: Kind : is : other : alias
6, Run Applescript:
Writes out broken alias PATHS to a property in the storage script file.
on run {input, parameters}
set file_path to (path to documents folder as Unicode text) & "MyProperties.scpt" as alias
set script_text to load script file_path
set broken_alias_file_Paths of script_text to input
my RunMaker(script_text)
return input
end run
on RunMaker(script_text)
set file_path to (path to documents folder as Unicode text) & "MyProperties.scpt"
set file_path to POSIX path of file_path as string
store script script_text in file_path with replacing
end RunMaker
7, Ask for Finder Items: This is for the Original files folder.
8,Run Applescript:
Writes out the Original files folder to a property in the storage script file.
on run {input, parameters}
set file_path to (path to documents folder as Unicode text) & "MyProperties.scpt" as alias
set script_text to load script file_path
set theOriginalFolderPath of script_text to (POSIX path of (item 1 of input))
my RunMaker(script_text)
return input
end run
on RunMaker(script_text)
set file_path to (path to documents folder as Unicode text) & "MyProperties.scpt"
set file_path to POSIX path of file_path as string
store script script_text in file_path with replacing
end RunMaker
9, Run Applescript:
This retrieves the information from the storage script. This will take the list of paths of the dead alias files.
Try and Find a matching file in the Original files folder. It will look at all matches but ignore aliases.
Remove the old Alias file (checking it is a alias file first)
Create a symlink in the folder the old alias was in from the matching file found.
Only alias files should be deleted. If no matching file is found then the alias file will not be deleted. Nor will a symlink be created.
.
set file_path to (path to documents folder as Unicode text) & "MyProperties.scpt" as alias
set theScript to load script file_path
--choose a search folder
set searchPath to quoted form of theOriginalFolderPath of theScript
set folderPath to quoted form of theBrokenAliasFolderPath of theScript
set input to broken_alias_file_Paths of theScript
repeat with i from 1 to count of items of input
set this_item to item i of input
set aliasPath to this_item
#Get the the file name
set theFileName to "\\\"" & (do shell script "basename " & quoted form of (POSIX path of (this_item))) & "\\\"" as string
log theFileName
#search the searchPath for a matching file with the same name.
#NOTE: this will find all files with he same name. So We use last paragraph to get what should be the first one it finds.
set theOrigFilePath to paragraphs of (do shell script "mdfind -onlyin " & searchPath & " kMDItemFSName == \"" & theFileName & "\"")
if theOrigFilePath is not quoted form of "" then
repeat with i from 1 to count of items in theOrigFilePath
set this_item to item i of theOrigFilePath
log this_item
tell application "Finder"
#make sure we are pointing to an alais that will be deleted and not another symlink file. Otherwise the original file will be deleted.
set theKind to kind of ((POSIX file this_item) as alias)
if theKind is not equal to "Alias" then
set this_item to quoted form of (item i of theOrigFilePath)
my symLink(aliasPath, this_item)
end if
end tell
end repeat
end if
end repeat
on symLink(aliasPath, aOrigFilePath)
#move to trash the old alias file
set theOldAlias to aliasPath
tell application "Finder"
#make sure we are pointing to an alais that will be deleted and not another symlink file. Otherwise the original file will be deleted.
set theKind to kind of theOldAlias
set theNewFilePath to (POSIX path of (aliasPath)) as string
if theKind is equal to "Alias" then
delete theOldAlias
log "ln -s " & aOrigFilePath & space & (quoted form of theNewFilePath)
#create the symlink
do shell script "ln -s " & aOrigFilePath & space & (quoted form of theNewFilePath)
end if
end tell
end symLink
Test first.. use at your own risk and all that..
As to your second question, I would try Tagscanner (https://www.xdlab.ru/en/). You can tell it the location of the files you want to edit tags for. So there is no danger of editing the set wrong files. It also has a batch mode. Read the documentation, as with many powerful tools, it has a lot of features that can seem overwhelming to new users. It also has a preview mode for changes that allows to to see the changes you are making before committing them.
Best Answer
I’ve put together a little AppleScript for you. If you use the Script Editor to save it as an applet you can drag & drop folders on it. The script will first ask for the destination folder and then scan the dropped folders for any aliases contained. If it finds any it will copy the original items to the destination folder specified.
Here’s the code:
It is neither pretty nor feature complete but rather meant to show you a possible way to go. I. e. it doesn’t traverse any subfolders. Also, there’s no checking of file existence before copying. Anyway, it might still be what you need. Have fun!