I am working on a script that will move the entire contents of a folder, including all subfolders and the files within, to another folder when I mount my bak drive.
Just for testing I wrote a simple script to check how I can do this (I don't really know AppleScript, so it's learn as I go), I used the following cmd in my applescript:
move every file of entire contents of folder "Lion:Users:dbooster:desktop:outbox" to "Lion:Users:booster:desktop:file"
So my test, as you can see is moving everything within a folder on my desktop called "outbox" into a folder called "file" on my desktop.
At first I thought it worked perfectly, but then I tried to put another folder within "outbox". What I discovered is this script moves all the files within that subfolder in "outbox", but it doesn't move the subfolder itself.
That is to say, if I test with outbox/stuff/file1.txt and run the script, the result is file/file1.txt, NOT file/stuff/file1.txt which is what I would expect.
Uhm... This seems like it should be easier than I am finding it. But I've been searching google for the past hour and can't come up with anything (maybe I'm searching for the wrong thing?) Any help would be appreciated -- thanks in advance.
Try:
tell application "Finder" to move entire contents of folder "Lion:Users:dbooster:desktop:outbox" to folder "Lion:Users:booster:desktop:file"
Related
I have close to zero AppleScript experience and very little Automator experience too, so please bear this in mind. What I'm asking might be REALLY obvious to you, but I'm somewhat stuck.
I want to create a workflow (saved as an App) where I can drag a folder and it does a few things:
Copies the source folder
Sets some background colors on the copied folders
Deletes any folders that are empty
I found a script that does the deletion, but it was set to reference a specific folder. I want it to reference the folder that I have just copied:
tell application "Finder"
set the_items to every folder of entire contents of folder "$CopiedFolderHere"
...
Image of the Workflow is here
I would really appreciate it if someone can tell me what I need to tweak in the script to allow it to make the deletions on the newly-copied folder.
Thanks :)
I have folders in folders in folders full of music I wanted to make it easy for me by putting all the music files from the same artist in the same folder but this would take days doing it manually...
Expl: All the Elvis music goes into the Elvis folder can be created by me or with a script (creating a folder is easy) and this process goes on for the rest of my music files with other artist...
I don't know if it is possible to use the file details "artist tab" to sort this?
I Tried the Move-Item but no succes
any advice?
greetings
This seems to not work, but it does a lot of the work that you are looking for. http://www.faqforge.com/windows/windows-powershell-script-to-sort-music-from-folder-to-library/
i use this module and dll for that sort of work:
http://powershell.com/cs/blogs/tobias/archive/2011/01/25/reading-and-writing-tags-to-videos-and-music.aspx
I need to MOVE (not copy) every file (including subfolders) in "Downloads" to an external drive called "Drive" in the location "Volumes/Drive/Apple/MacBackup/Downloads". I have tried countless times and it is just not working... Here is my code right now:
tell application "Finder" to move entire contents of folder "Users:myUsername:Downloads" to folder "Drive:Apple:MacBackup:Downloads"
I am getting the error:
Finder got an error: Can’t get folder "Users:myUsername:Downloads".
HFS paths have to begin with the name of the disk, like
"Macintosh HD:Users:myUsername:Downloads"
You have probably taken it from a POSIX path, were the first slash represents the startup volume.
To be sure just run
choose folder
and copy the path from the result.
The error is because that is not a correctly formed path. You should use the special folder designation (path to downloads folder).
tell application "Finder" to move entire contents of (path to downloads folder) to folder "Drive:Apple:MacBackup:Downloads"
Also, I would strongly encourage you to copy the files, then delete the old files. Moving files is asking for trouble if something happens mid-process, and it's lost in transit. (think star trek transporter problem)
If you've ever saved a a full webpage you'll notice that it creates the .htm file and a folder that contains all the icons and scripts for the page.
If you move the .htm file to a new location, the folder that came with it moves to the same location, and the behavior is the same if you move the folder, the .htm file will move with it.
How can I do that with any old file/folder combination? Can this be manipulated?
EDIT: Programmatically (through CMD)
Is there a command that binds files to other files etc.?
This is a feature of the shell called Connected Files. It is specifically implemented for web pages; it is not generic or extensible as far as I know.
It doesn't even seem that useful to me as it only works when using the shell mechanisms (SHFileOperation and friends); if plain old CopyFile/MoveFile are used then all the files need to be handled individually.
I need to rename image files sequentially as they are added to a folder. ie. image-0001.jpg and image-0002.jpg are in a folder I add test.jpg and it is renamed image-0003.jpg. I have tried automators rename function but it will start over with image-0001.jpg each time a new file is added instead of continuing the sequence.
Any help is greatly appreciated.
You could make this easy on yourself by using a handy application built into the OS called "Folder Actions". Folder Actions contains one or more special handlers, formally known as folder action event handlers, that run when they are triggered by a change in the target folder. I know I'm confusing but I'll do my best.
What you are trying to accomplish requires an adding folder items to event handler. It requires one direct parameter, which can be anything you wish i.e. target_folder. The handler requires an additional parameter as well; after receiving, which should also be a variable name, i.e. these_items. I have composed a script for you that should do the trick. I have added comments that show you what I'm doing when I do it. Here it is:
on adding folder items to the target_folder after receiving these_items
tell application "Finder"
set all_images to every item of the target_folder as list
repeat with i from 1 to the count of these_items --iterates through all the items you dropped in the folder
set this_image to item i of these_items --the current image
set the name of this_image to "image" & (i + the count of all_images) as string --renames the image based on the number of images already in the folder
end repeat
end tell
end adding folder items to
YAY! The script is done! But are WE done? Not quite. We still need to attach the script to a folder (the script won't run if you try to execute it in script editor).
To do this, first save the script as a Script File in the Folder Action Scripts folder in the Scripts folder in either the local Library folder or the current user's Library folder. Create the folder yourself if it doesn't already exist. Next, launch the Folder Actions Setup application by double-clicking it in the AppleScript folder in the Applications folder. In the window that comes up, click the + button under the table on the left (click the "Enable Folder Actions" checkbox if it isn't already checked) to open a standard file browser sheet, navigate to your desired folder, and click "Open". The Choose a Script to Attach sheet automatically opens, listing all the scripts in all of the Folder Action Script folders. Choose the newly-created script, click "Attach", and BAM you are done!
To see the script in action, drag an image onto the folder. The image is instantly renamed, regardless of if the folder window is open. If you have any questions, or if the script doesn't work, just ask me. :)
well without digging through some code and handin you an answer I'll tell you want you want to do
is create a while loop that checks for the existence of image-000 & i where i is a variable of course and if it exists increment i then when the file doesn't exist rename your file.