Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MortI80

macrumors newbie
Original poster
Jul 30, 2015
2
0
Hi guys,

I already searched a lot but cannot find a solution. I have a list of files on an external drive and want them all to be copied into one certain folder, e.g. "/Volumes/Data/all_not_imported_files"
"/Volumes/Data/Vids/Video0270.mp4"
"/Volumes/Data/Vids/Video0271.mp3"
"/Volumes/Data/Vids2/Video0270.pdf"
"/Volumes/Data/Vids2/Video0271.doc"​
the list is pretty long, therefore I thought automation with apple script would be great. However, I do not understand how to use this list with apple script using the right syntax.

Here are my Targets: if the filename is the same, still move the file from the source to the target folder but add a number to the new name and leave the file extension untouched.

Additional Information: the files are files that have not been imported to iphoto due to the wrong file formats. Most of them are videos, but not all. And some videos have been imported. The whole thing is about importing videos and pics to iphoto from an old library and move all not imported files to one folder. After that I can begin to convert this files and import them afterwards.

Do you have any ideas? I already tried the following, but the name of the file can not be read...
Code:
set theFile to "Data:Vids:Video0270.mp4"
set theDestinationFolder to "Data:all_not_imported_files"
tell application "Finder"
    set theFileName to name of theFile
    set thePathToCheck to theDestinationFolder & theFileName as string
    if item thePathToCheck exists then
        set theSuffix to 1
        repeat
            if (item (thePathToCheck & theSuffix) exists) = false then exit repeat
            set theSuffix to theSuffix + 1
        end repeat
        set name of theFile to theSuffix & theFileName
    end if
    move theFile to theDestinationFolder
end tell
 
Your problem seems to be that theFile and theDestination folder are strings, not aliases. Change it to something like:

Code:
set theFile to alias "Data:Vids:Video0270.mp4"
set theDestinationFolder to alias "Data:all_not_imported_files"

I haven't time to go through the rest of your code, but that should get you over your first hurdle. ;-)

Good luck.
r.
 
Thanks superscape,

with your hint I was able to figure it out. Now, it is possible to move one file to another location without overwriting files with the same names. However, the best would be to be able to read a txt.-file with all paths and use these ones as the source.

In addition to that - is it possible to tell the finder via iphoto that if a picture or video is already imported into the iphoto-library, that it should be deleted in the folder from which it is imported? Or to move the already imported files to a specific folder and the not-imported ones to another location? I just try to find a good way to import old data and check if they have already been imported or not...

Code:
moveFilesToFolder("Data:Vids:Video0270.mp4")

on moveFilesToFolder(FilePath)
    set theFile to alias FilePath
    set theDestinationFolder to alias "Data:all_not_imported_files"
    tell application "Finder"
        set theFileName to name of theFile
        set thePathToCheck to theDestinationFolder & theFileName as string
        if item thePathToCheck exists then
            set theSuffix to 1
            set thePathToCheck to theDestinationFolder & (theSuffix as string) & theFileName as string
            repeat
                if (item (thePathToCheck) exists) = false then exit repeat
                set theSuffix to theSuffix + 1
                set thePathToCheck to theDestinationFolder & (theSuffix as string) & theFileName as string
            end repeat
            set newFileName to theSuffix as string
            set name of theFile to newFileName & theFileName
        end if
        move theFile to theDestinationFolder
    end tell
end moveFilesToFolder
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.