Unlocking files with Automator
I have an external drive containing folders and files which were loaded from CD's. All the files are locked. Is there a way I could use automator to unlock all the files in a particular folder?
A few different ways.
You could select all of them in the Finder and unlock (or lock) them in the Inspector, a variation of the Info window. Usually you would choose "Get Info" from the Finder's File menu. However, if you hold down the Option key, the "Get Info" changes to "Show Inspector". It's actually the same thing except you don't get a separate window for each file, but instead a single panel. (The panel will stay in view above everything else in the Finder, and will show info about whatever is currently selected.) Within that, in the General area near the top (below the Spotlight comments), there is a checkbox for locking the files. Just uncheck that to unlock.
Another option is to use AppleScript, perhaps inside a "Run AppleScript" action in an Automator workflow. You'd probably have one of the Finder's actions first, such as "Get Selected Finder Items" for anything you currently have selected in the Finder, or perhaps "Get Specified Finder Items". You'd then add Automator's "Run AppleScript" with the following:
<pre style='border:2px inset #99f;overflow:auto;width:500px;padding:.5em;color:#000;background:#ccf';>on run {input, parameters}
tell application "Finder"
repeat with theItem in input
set locked of theItem to false as boolean
end repeat
end tell
-- pass the items to the next action
return input
end run</pre>
(The line beginning with "--" is just a comment, so it's ignored and you don't really need it.)
On the other hand the above code is directly from the Automator action I made to unlock files and folders, which isn't much different than the other action I made to lock them. If you'd like to install the actions, you can download them from the Mac OS X Downloads page here:
http://www.apple.com/downloads/macosx/automator/lockandunlockfilesandfolders.htm l
Besides being a Universal build, I've included example workflows for locking (or unlocking) items in the Finder. They are meant to be saved as Finder plug-ins so you can right-click on an item (or group of items) and choose to lock/unlock from the Automator submenu in the Finder's contextual menu.
The Finder's contextual menu is also available with Control-click, or with the action button (a gear on it) in the toolbar of Finder windows. If I remember correctly, I've included instructions with the download on how to install the actions and how to save Finder plug-ins, if you aren't familiar with that already. Simply put, you install actions with Automator by choosing in the File menu "Import Actions...".
(There's also a bonus workflow I named " Edit Menu..." for easily accessing the workflows in the Automator submenu. It opens a Finder window with the location of the Finder plug-ins so you can rename them or open them for editing. Though, Spotlight can be just as good for locating them. )
So, there you go. Three different ways. Hopefully one of those will be appropriate.
Similar Messages
-
Renaming files with Automator & Apple Spript
Hi there!
I need the help of an expert in Automator & Apple Spript....
I've got to rename 500 files with the following names:
001-001 firstfilename.jpg
104-095a otherfilename.jpg
Any idea on how to get rid of the second number (that is 3 or 4 characters long, but always followed by a space) so to have something like:
001 firstfilename.jpg
104 otherfilename.jpg
Thanks in advance & Ciao!
Sergio
Black MacBook Mac OS X (10.4.7)The following script should work.
IMPORTANT:
1) The files whose names you want to change must all be in the same folder. That folder must be open, and it must be the front finder window.
(Also, no other files should be in that folder)
2) Make a back-up of the files before you do this (just in case there is a problem. I hope the files are not too large)
3) This should work if the file names are consistent. I have presumed that there is always a hyphen and a space ( ) and that you wish to keep the characters before the hyphen and after the space.
4) Copy the script below into the script editor. When you have prepared 1 & 2 above then run the script. Good luck
--Start of Script
tell application "Finder"
set myFiles to every file of the front window
repeat with Cfile in myFiles
set WholeName to the name of Cfile
set AppleScript's text item delimiters to "-"
set WNlist to every text item of WholeName
set WNpart1 to first item of WNlist
set AppleScript's text item delimiters to " "
set WNlist2 to every text item of WholeName
set WNpart2 to last item of WNlist2
set NewName to WNpart1 & " " & WNpart2
set name of Cfile to NewName
end repeat
end tell
set AppleScript's text item delimiters to ""
--End of Script
MacBook Mac OS X (10.4.7) iMac G4 (10.3.9) -
Move Files with Automator or Applescript
I am a newbie to Applescript and Automator and I'm afraid I'm in way over my head. I need to move a bunch of files in a single folder to several different folders based on the file name. Is this possible?
Specifically, several files with names "word1 word2 word3 word4.pdf" are placed in a folder then they will be moved to different folders based on word4.
Ideally, if possible, I would then have to append to things to the file name. At the beginning of the file name a three digit code based on word4 (or the folder) and then at the end of the file name a date stamp. The date stamp should be in the form of four digit year, two digit month, and two digit day with no spaces in between. Where, year is the year of current month -1, month is current month -1, and day is the last day of current month -1.
Is there any way to do this?
Thanks!your description is still underspecified, so this script probably won't work out-of-the-box, but it will get you close.
on adding folder items to this_folder after receiving these_items
repeat with thisItem in these_items
set fileName to nameWithoutExtension(thisItem)
set accountName to last word of fileName
set accountCode to codeForPerson(accountName)
set dateSlug to dateString()
set newFileName to accountCode & " " & fileName & " " & dateSlug & ".pdf"
tell application "System Events"
-- you haven't specified actual file path, so I'm assuming your destination folder is inside your folder action folder
set destinationFolder to folder "Statements" of folder accountName of this_folder
set movedFile to move f to destinationFolder
set name of movedFile to newFileName
end tell
end repeat
end adding folder items to
on nameWithoutExtension(p)
tell application "System Events"
set {n, x} to {name, name extension} of p
end tell
return (text 1 thru -((length of x) + 1) of n)
end nameWithoutExtension
on dateString()
set d to current date
set day of d to 1
set {y, m, d} to {year, month, day} of (d - 1 * days)
return (y as string) & zeroPadDigit(month * 1, 2) & zeroPadDigit(day, 2)
end dateString
on zeroPadDigit(d, p)
return text -p through -1 of ("000" & d)
end zeroPadDigit
on codeForPerson(n)
if n = "Smith" then
return "001"
else if n = "Jones" then
return "002"
else if n = "Doe" then
-- you haven't specified how these numbers are determined
else
-- return default value for unspecified accounts
end if
end codeForPerson -
Opening a Unix Exec file with Automator
So i downloaded a game called Starbound from Steam onto my mac. To host a server, you need to start the starbound_server Unix Exec file. This file opens in Terminal, and runs a bunch of stuff. So, on my mouse i want to create a Macro that allows me to launch it.
I want to create a service in Automator that i can assign a shortcut to which i can therfore set as a macro on my mouse.
So my question is, what do i do? The 'Launch Application' function won't open it, its greyed out when i go to find it. Is there any Automator function that will allow me to open this file?
For ease of providing answers, the file path is:
/Users/---/Library/Application Support/Steam/SteamApps/common/Starbound/Starbound.app/Contents/MacOS/starbound _server
Any help appreciated!Hello
You may try using "Run Shell Script" action with the following contents:
~/'Library/Application Support/Steam/SteamApps/common/Starbound/Starbound.app/Contents/MacOS/starbound_server' &>/dev/null &
which will run the executable in background.
The service workflow will look something like this:
Regards,
H -
How do I managing files with Automator?
Hello!
I looked around in many websites, but didn't found one solution that works for me.
I tried to do one workflow by myself but even so it didn't work.
Maybe this is a simple problem for someone who knows how to work with automotor. But for me it's been a hard task.
I have one "folder A” with files and subfolders, and a "folder B” also files and subfolders (some are the same).
The “folder A”is managed by one software program.
I need when a file is added to "folder A" this will be excluded/deleted from "folder B”.
This will prevent duplicating files.
Someone could help me with this?
Thank you in advance.How do you attach the pdf to the citation?
Inside the program exist one space to attach the file.
Is it done from within the program (what program BTW?) or is it done from outside the program.
The program is the "Endnote".
Is there some way to tell the program to move the PDF file rather then copying it?
I suppose not.
If not is there some way to have the program output a list of the PDF files?
I don't know, I suppose not.
Thanks -
I want to have a automator function that downloads from a FTP server movies/files.
Then I want to take those files and send them to a compressor droplet and automatically run and process.
How do I pass the files from the folder that they are being downloaded to, into the droplet?
I am using Transmit to download.My apologies, I read the first post as "I have an automator function that downloads from a FTP server..."
You could try something like:
1) Get Specified Servers
2) Connect to Servers
This returns the mounted server. Depending on how the server is set up, and what files you are interested in, you can put some combination of "Get Folder Contents" (to get everything in the server) and "Filter Finder Items" (to pick just the folders/files you are interested in).
Then...
x) Copy Finder Items
- here you can specify where you want the files copied to
x+1) Then you can do the "Open Finder Items" like I mentioned in the earlier post.
Hope it helps! -
Open random image file with automator
I would like to open a random file from a folder in Preview.
I've looked into the finder and photo presets but can't figure a way out. Is there a script I can run or have I just missed something?
What I'm basically looking to do is for Automator to look within a folder and open an image in it's default application.Hi Niel,
I've still got the same issue. -
Importing text file (with file names) into Automator.. is it possible?
Hello all,
I have been working with Windows Batch files for my line of work. I have a couple of file names in a text file (a column), which I want to copy from one folder of one hdd to another folder on a different hdd. I have been trying to do this kind of work with a Mac. I already know how you copy and rename files in automator (which isn't difficult, of course) but you have to 'select' the files in the finder first (with get specified items).
But the only way i see that you can specify items is by selecting them... is there a way to import a text file with all the file names instead of selecting all the file names manually?
or is there an AppleScript alternative which I can use to import the text file (or just copy into applescript) and run before the query's of copying and renaming the files? I am kind of new to Apple programming.
The text file looks like this:
image1.jpg
image2.jpg
etc..
so there has to be a command to: 'goto' a specific folder as well.
Thanks in advance!You can import text files, but if they are just names you will need an additional action to add the source folder path. A *Run AppleScript* action can be used, for example:
Tested workflow:
1) *Ask for Finder Items* {Type: files } -- choose the text file containing the names
2) *Combine Text Files* -- this gets the text file contents
3) *Filter Paragraphs* { return paragraphs that are not empty } -- skip blank lines
4) *Run AppleScript* -- copy and paste the following script:
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
font-weight: normal;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 680; height: 340px;
color: #000000;
background-color: #FFEE80;
overflow: auto;"
title="this text can be pasted into an Automator 'Run AppleScript' action">
on run {input, parameters} -- add folder path
add the specified folder path to a list of file names
input: a list of text items (the file names)
output: a list of file paths (aliases)
set output to {}
set SkippedItems to {} -- this will be a list of skipped items (errors)
set SourceFolder to (choose folder with prompt "Choose the folder containing the file names") as text -- this is the folder containing the names
repeat with AnItem in the input -- step through each name in the input
try
set AnItem to SourceFolder & AnItem -- add the prefix
set the end of the output to (AnItem as alias) -- test
on error number ErrorNumber -- oops
set ErrorNumber to (" (" & ErrorNumber as text) & ")" -- add the specific error number
set the end of SkippedItems to (AnItem as text) & ErrorNumber
end try
end repeat
ShowSkippedAlert for SkippedItems
return the output -- pass the result(s) to the next action
end run
to ShowSkippedAlert for SkippedItems
show an alert dialog for any items skipped, with the option to cancel the workflow
parameters - SkippedItems [list]: the items skipped
returns nothing
if SkippedItems is not {} then
set {AlertText, TheCount} to {"Error with AppleScript action", count SkippedItems}
if TheCount is greater than 1 then
set theMessage to (TheCount as text) & space & " items were skipped:"
else
set theMessage to "1 " & " item was skipped:"
end if
set {TempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
set {SkippedItems, AppleScript's text item delimiters} to {SkippedItems as text, TempTID}
if button returned of (display alert AlertText message (theMessage & return & SkippedItems) ¬
alternate button "Cancel" default button "OK") is "Cancel" then error number -128
end if
return
end ShowSkippedAlert
</pre>
5) *Copy Finder Items* { To: _your external drive_ } -
Automator or Applescript using png files with alpha channel
I have hundred of png files with alpha channel.
I want to suppress alpha channel.
How can i do it using Automator or Applescript ?
Thank you very much.You can use the free command line image processing tool ImageMagick in your Applescripts or Automator workflows, as well as from a Terminal shell.
You can download ImageMagick from http://www.imagemagick.org, but Cactuslab has simplified installation by putting together an installer package. It’s available at http://cactuslab.com/imagemagick/. Download the package and double-click on it. Follow the instructions to install. It will install ImageMagick into /opt/ImageMagick and add it to your $PATH by creating a file in /etc/paths.d/. Restart your computer for the changes to take effect.
The two ImageMagick commands we’re concerned with are “convert” and “mogrify”. Convert is more efficient for multiple and piped operations on the same image file, and mogrify is more efficient for batch processing. Generally speaking, convert will output a file separate from the input file. Unless a path is specified, mogrify will overwrite the input file with the output file. An important distinction.
You can perform various operations on the alpha channel using arguments after either the convert or mogrify command. Two of the available arguments are:
-alpha off - Disables the image's transparency channel. Does not delete or change the existing data, just turns off the use of that data.
-alpha remove - Composite the image over the background color.
Also of use are the -flatten and -background options:
-flatten - overlay all the image layers into a final image and may be used to underlay an opaque color to remove transparency from an image.
-background - sets the background color.
Start off using the convert command with a single image to see the effect and adjust to your liking. Once you’ve achieved the desired outcome, then use the mogrify command to batch process the chosen images.
Before getting into how to use Automator or Applescript in your workflow, use Terminal and the command line to see the effect on a single image. Copy one image to your ~/Desktop. In Terminal change the directory to ~/Desktop by typing the following command and pressing the Enter key:
cd ~/Desktop
Then choose the option you are looking for, -alpha remove for instance, type the following command and press the Enter key:
convert input-photo.png -alpha remove output-photo.png
You can check the alpha channel (transparency) and background in the Preview app, go View > Show Image Background from the menu bar.
Once you’re ready to batch proces, place all the photos you want to convert with the same command into one folder. Copy the folder to your ~/Desktop. Let’s assume you’ve labeled the folder “InPhotos”. It’s prudent to manipulate copies in case something goes amiss. In that event you can copy the folder with the originals again and start over. Create a new empty folder on your ~/Desktop and call it “OutPhotos”. Let’s also assume your home directory is called “Me”. The following command will process the photos from the InPhotos folder and put them in the OutPhotos folder:
mogrify -alpha remove -path /Users/me/Desktop/OutPhotos/ /Users/me/Desktop/InPhotos/*png
According to Apple Technical Note TN2065:
"when you use just a command name instead of a complete path, the shell uses a list of directories (known as your PATH) to try and find the complete path to the command. For security and portability reasons, do shell script ignores the configuration files that an interactive shell would read"
So, you need to use the full path to to ImageMagick commands, unlike in the shell where you can just use the command name.
To batch process using Automator, use the “Run Shell Script” action (note: retain the single space at the beginning of the last line):
/opt/ImageMagick/bin/mogrify \
-alpha remove \
-path /Users/Me/Desktop/OutPhotos/ \
/Users/Me/Desktop/InPhotos/*png
To batch process using Script Editor (Applescript), use the “do shell script” command:
do shell script "/opt/ImageMagick/bin/mogrify -alpha remove -path /Users/pd/Desktop/OutPhotos/ /Users/pd/Desktop/InPhotos/*png"
Further info on ImageMagick:
http://www.imagemagick.org/script/command-line-options.php#alpha
http://www.imagemagick.org/Usage/masking/#remove
http://www.imagemagick.org/index.php
http://www.imagemagick.org/script/command-line-tools.php
http://www.imagemagick.org/script/command-line-options.php
Examples:
The original PNG image:
-alpha off:
-alpha remove:
-background black -flatten:
-background blue -flatten:
-channel alpha -evaluate Divide 2:
-channel alpha -evaluate Divide 2 -background black -flatten: -
How to find duplicate files in Finder with Automator or Apple ScriptEditor
Can anyone tell me how to find duplicate files in Finder with Automator or Apple ScriptEditor.
D'oh! It's actually fairly easy - I just right clicked on the file, Get Info, Artwork tab, then dragged the picture to the desktop, from where I can do what I like with it. Never mind, nothing to see here, carry on.
-
Moving files to the Trash with Automator
I'm having some problems with Automator, and I'm hoping it's just a simple step I'm missing.
I have a list (text file) of a group of files I wish to remove from a folder (about 650 or so files, from a folder of about 8000). I have been able to get Automator to read the text file, and show me the result.
(Ask for Finder Items (Files & Folders), Combine Text Files (Text), Filter Paragraphs [Return Paragraphs That Are Not Empty] (text))
This results in showing me my list of files I wish to remove.
I don't quite get how to pass this list on to the Finder to tell it to select these files, and move them to the trash.
Any assistance would be appreciated.Since your text file just has the names, an action is needed to build the complete file path. Most of Apple's text and file actions don't use variables, but a Run AppleScript action can be used to fill in the blank. Give this workflow a try (I haven't tested it with a large number of files, so I don't know how slow it will be):
1) Ask for Finder Items {Files} -- choose the text file
2) Combine Text FIles
3) Filter Paragraphs {Return paragraphs that are not empty}
4) Run AppleScript -- paste the following script:
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
font-weight: normal;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #FFEE80;
overflow: auto;"
title="this text can be pasted into an Automator 'Run AppleScript' action">
on run {input, parameters} -- build file paths from a list of names
set output to {}
set SkippedItems to {}
set TheFolder to (choose folder with prompt "Select the folder containing the files:") as text
repeat with AnItem in the input
try
set AnItem to (TheFolder & AnItem)
get AnItem as alias -- test
set the end of the output to the result
on error
set the end of SkippedItems to AnItem
end try
end repeat
if SkippedItems is not {} then
display alert "Error with AppleScript action" message ((count SkippedItems) as text) & " items were skipped (file not found)"
end if
return output
end run</pre>
5) Move Finder Items to Trash -
Help with Automator - create workflow to move files to dated folders
If anyone could help me, I'd greatly appreciate it.
I have no idea how to use Automator, but I think it'd be perfect for this job.
I want to take a folder of files (images) and move them to separate folders which are named for the dates that the files were created on. So, for instance, I have a folder of ten images. Five were created on November 1st and the other five were created on November 2nd. I want to create two folders on the desktop with the dates in the name (like 20071101 & 20071102) and take the five images from 11/1 and move them to the 20071101 folder and the five images from 11/2 and move them to the 20071102 folder (sorry for the run-on sentence).
Is this possible with Automator? Is this an easy thing to do?
Thanks,
AntonioI'm trying to do something very similar. I need to open an image sequence in QuickTime and export them to a mov file. Easy enough, but I would also like to create a new Finder folder and name it with today's date and save the mov file to that new folder.
What frustrates me is that it doesn't appear you can name Finder folders in any way other than using the Rename Folder action. I was hoping to use today's date that I had copied to the clipboard. Also, I have no experience using AppleScript, so hoping to avoid anything advanced there. -
Open File with Application in Automator - Bug???
I have created a simple workflow to open a text file with TextEdit. It seems to work once, then subsequent times the workflow goes to the point that TextEdit opens but the file doesn't open along with it.
I have encountered the same type of problem when trying to open other files with other applications - the applicaton opens but the file is not passed along with it.
I am only using two actions:
(1) Get Specified Finder Items
(2) Open Finder Items
I noticed there is another Finder action that doesn't seem to do anything called "Get Selected Finder Items"
Am I doing something wrong?
Help....I'm not sure about your main problem, but I can tell you about the "Get Selected Finder Items" action.
That action refers to the items you have selected in the Finder. Selected items in the Finder are highlighted. So, if you haven't selected anything in the Finder yet, then the action will not have anything to give the workflow.
In essence, this action allows you to specify an item (or items) each time you run a workflow merely by selecting an item in the Finder, instead of having to specify an item permanently in the workflow. That is, you don't have edit the workflow in order to use it for another item. So you don't need multiple copies of the workflow, each specifying a different file or set of files.
Hope that clears up the mystery of that action.
MacBook 2.0 GHz Intel Core Duo Mac OS X (10.4.8) 512 MB RAM -
Can anybody help me with comparing the two pdf files with the help of QTP.I have Adobe Acrobat installed on my system and i have access to the API.
Thanks,
Varun SainiI want to find out more about QTP and API. Maybe that is what I want to compare two mechanical drawings for differences between them. (see “More than one pdf file in one window”. Is that what you are looking to do? 9Not necessarily mechanical drawings but some other pdf).
-
AppleScript open and save file with Numbers
Hi all,
I need to save an Excel .xls file as an .xls file in order to break the links that are included in the original Excel file. Since Numbers doesn't have any actions for Automator, I hoped someone could help me writing an AppleScript?
It needs to open (Numbers) and all the .xls files that are added to a specific folder on my Mac, then save them to another folder as .xls (not .xlsx) and overwrite any existing files with same name. Since this all should work automatically, warnings and pop-ups that need a user to click an option are not allowed.
Didn't think this could be too hard, but I'm just a noob when it comes to AppleScript. Help?
Thanks in advanceCheck the attributes of the <textarea> tag. You can use wrap="no" or wrap="virtual" or wrap="hard" to define how the text area handles carriage returns.
Brian
Maybe you are looking for
-
Does something like this exist for mac somewhere?
http://www.bitboost.com/pawsense/ I've recently gotten a cat that loves my desk and keyboard. I've had to resort to unplugging my keyboard whenever i'm not by it. While it isn't a big deal, i'd prefer it if i didn't have to. Is there something simila
-
Need to change acct to Canadian from American but it won't let me without using up my balance of $1.27. There is no way to spend exactly this amount. I do not want to use a credit card. I have a Canadian iTunes card that I want to redeem now that I'
-
Opens to a blank screen with the little color wheel running indicating that something is running everytime I put my mouse on page. I also cannot close the page or do anything concerning this page when the little wheel is running. This has gone on for
-
Simple question. How do you convert an album in to an Event?
-
Common itunes and iphoto library across many apple devices & users using AExtreme?
Is it possible to maintain a common itunes library and iphoto library shared across multiple users and multiple devices in a home via airport extreme or via airport express and a NAS?