Applescript: Move file to hidden folder

I'm trying to move a file from a non-hidden folder to a hidden folder. I do not want to make the file visable, so that is not an option.


Here is my Code:


set theFile to the_string & "prefs.js"

set JAMF to "Library:Application Support:JAMF:JamfCustomApps:prefs.js"

set JAMFNew to (POSIX path of JAMF) --Testing to see if I needed the other path string



tell application "System Events"


moveJAMFtothe_string

end tell

Posted on Apr 28, 2014 12:18 PM

Reply
7 replies

Apr 28, 2014 1:35 PM in response to GaToRAiD

Files within a hidden directory remain hidden unless you have access to a shell (Terminal.app). If I'm not mistaken, /Library is owned by the root user in your version of OS X. So, you may need administrator priviledges to install your file.


Actually, applescript seem like a roundabout way to accomplish your goal. Assuming that the directory- /Library/Application Support/JAMF/JamfCustomApps/ exists then using the shell (Terminal.app) could be done with this one line ->


sudo install -o 0 -g 0 -m 644 /path/to/prefs.js /Library/Application Support/JAMF/JamfCustomApps/

/path/to/ would have to be changed to the absolute path to the file.

Apr 28, 2014 1:51 PM in response to Mark Jalbert

Guys so you can get the whole story. Basically I'm trying to drop a "prefs.js" file into the directory that Firefox makes so that I can set settings for users. Here is my whole script so you can see what it does:


tell application "Finder"

try

tell application "Firefox"


activate --Opens Firefox to create prefs.js

end tell

end try

try

tell application "Finder"

set the visible of process "Firefox" to false --Tell's firefox to open minimized

end tell

end try

end tell


tell application "Firefox"


quit --Closes firefox

end tell


set FolderPath to ((path tohome folderasstring) & "Library:Application Support:Firefox:Profiles") as text --Sets the directory so ~/Library/Application\ Support/Firefox/Profiles/

set the_string to ""

tell application "Finder"

set myFolders to folders of folderFolderPath

repeat with this_item in myFolders

set the_string to the_string & (this_item as string) & return

end repeat

set the_string to items 1 thru -2 of the_string as string --Finds the randomly generated folder that is in the Profiles subfolder

end tell


set theFile to the_string & "prefs.js"

set JAMF to "Macintosh HD:Library:Application Support:JAMF:JamfCustomApps:prefs.js"

set JAMFNew to (POSIX path of JAMF)



tell application "Finder"


movefileJAMFtotheFile with replacing

end tell


The last step is the step to move the prefs.js file that will be dropped on the computer via a 3rd party application into the JamfCustomApps folder. Then copy that folder to the saved folder location from the previous step and overriding that file.

May 2, 2014 4:21 PM in response to GaToRAiD

bumping isn't going to help a lot - you've already been given the answer.


Fundamentally, your issue is not that the folder is hidden, it's that you're trying to copy the file to a protected location, therefore you're going to have to provide authentication credentials in order to make the move.


Unless you know a specific admin username and password on the target system, you'll need to invoke the user to authenticate.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Applescript: Move file to hidden folder

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.