How do you rename, or change permissions on many files?

**Note** there are SUDO commands here that can potentially wreck up your system.  If you have questions about this stuff, post in the forum or ask someone verbally to help.  The sudo command can really cause problems if you're not entirely sure what you're doing.
I had an issue a while ago where I had to rename about 400 pictures all in the same folder.  They were all named by a students PEN #.  I needed an incremental number starting at 001.jpg.  I was hoping to figure out a script either in apple script or in terminal that would do the job.  I called a friend of mine at another school with my problem (he's a windows guy) and he had this great idea.
First of all, using terminal list all the files.
The command is simply "ls" without the quotes.
Select all the files that the ls command outputs and copy it.  (command c)
Next, open up excel or numbers or any spreadsheet program, select cell B1 and paste the list of files in question.
When I type SPACE below, I mean hit the space bar. 
Now comes the fun part.
In cell A1 type mv SPACE
In Cell C1 type SPACE
In Cell D1 type 001
In Cell E1 type .jpg
In Cell F1 type the following.
Fill down each of the columns to the bottom of the list of file names.
A
B
C
D
E
F
G
mv
pennumber1.jpg
001
.jpg
=CONCATENATE(A1..E1)
mv
pennumber2.jpg
002
.jpg
=CONCATENATE(A2..E2)
mv
pennumber3.jpg
003
.jpg
=CONCATENATE(A3..E3)
mv
pennumber4.jpg
004
.jpg
=CONCATENATE(A4..E4)
mv
pennumber5.jpg
005
.jpg
=CONCATENATE(A5..E5)
Now Select all of column F and copy it.
Open up terminal and navigate to the folder that's containing all your files to be renamed.
Hit paste and press enter.
This will paste in the contents of each cell in the f column followed by an enter.
Voila!
Now, if you wanted to change ownership of a set of folders, you could use the same process. 
I'm assuming that the folder's that your changing are home folders here.  In other words, the home folder name should be the same as the shortname of your user.
It might look something like this:
Navigate to the folder that conains your user folders.  **CAUTION  ----SUDO AHEAD***  This command can BREAK YOUR COMPUTER if you're not careful.
Type:  sudo -s
type your password.
Copy the list of Folders from terminal.
Paste them into some column way on the right in excel or numbers or whatever.  Maybe column F or something.
Now, in A1 type chmod SPACE        and fill it down all the way.
In B1 type -R SPACE         and fill it down all the way
In C1 type =F1 SPACE       and fill it down all the way
In D1 type =F1       and fill it down all the way
In E1 type =CONCATENATE(A1..D1)        and fill it down all the way
The spreadsheet might look like this:
A
B
C
D
E
F
chmod
-R
=F1
=F1
=CONCATENATE(A1..D1)
thor
chmod
-R
=F2
=F2
=CONCATENATE(A2..D2)
incrediblehulk
Again, just copy and paste column E into terminal and poof!  It should work!
*Note, it might be a good idea to run a trial on a folder that's not important to you before you start.  These commands you're running can wreck things up pretty good.  So ensure things are set up properly before hand!
HTH
-Graham

In the Finder's Get Info window, under permissions, you can click the little gear icon and set the "Apply to encoded items" flag. Then when you change permissions, it will apply to everything underneath the selected folder.

Similar Messages

  • How do I change permissions on many files at once?

    Hello!
    I recently had a large hard drive crash, and, long story short, I got all my data back but now have a different user account on a new hard drive.  The permissions on all the files on the computer are fine.
    However, I am a recently graduated film student and use an external drive to edit video.  When I tried to open up Final Cut Pro and work on a project, I was told that the program couldn't work because I didn't have "write" access to my scratch drives.  I changed the permissions on the relevant folders and can now open the application fine, but can't actually edit because ALL the medi files don't give me full read/write access.
    I can change them all one at a time, which requires I enter my password for each one, but this would take a few days of work to complete.
    My question is: how can I add my user account with read/write permission to many files at once?  I've heard this can be done with Terminal, but I'm not sure how. 
    Please give me step-by-step instructions if you can!  I have never used Terminal before!  I am not a techie, but I want to be, and I learn quickly!
    My computer specs:
    15in Macbook Pro, early 2008.
    System 10.5.8

    In the Finder's Get Info window, under permissions, you can click the little gear icon and set the "Apply to encoded items" flag. Then when you change permissions, it will apply to everything underneath the selected folder.

  • Solved - How to take ownership and change permissions for blocked files and folders in Powershell

    Hello,
    I was trying to take ownership & fix permissions on Home Folder/My Documents structures, I ran into the common problem in PowerShell where Set-Acl & Get-Acl return access denied errors. The error occurs because the Administrators have been removed from
    file permissions and do not have ownership of the files,folders/directories. (Assuming all other permissions like SeTakeOwnershipPrivilege have been enabled.
    I was not able to find any information about someone successfully using native PS to resolve the issue.  As I was able to solve the issues surrounding Get-Acl & Set-Acl, I wanted to share the result for those still looking for an answer.
    Question: How do you use only Powershell take ownership and reset permissions for files or folders you do not have permissions or ownership of?
    Problem: 
    Using the default function calls to the object fail for a folder that the administrative account does not have permissions or file ownership. You get the following error for Get-Acl:
    PS C:\> Get-Acl -path F:\testpath\locked
    Get-Acl : Attempted to perform an unauthorized operation.
    + get-acl <<<< -path F:\testpath\locked
    + CategoryInfo : NotSpecified: (:) [Get-Acl], UnauthorizedAccessException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.GetAclCommand
    If you create a new ACL and attempt to apply it using Set-Acl, you get:
    PS C:\> Set-Acl -path F:\testpath\locked -AclObject $DirAcl
    Set-Acl : Attempted to perform an unauthorized operation.
    At line:1 char:8
    + Set-Acl <<<< -path "F:\testpath\locked" -AclObject $DirAcl
    + CategoryInfo : PermissionDenied: (F:\testpath\locked:String) [Set-Acl], UnauthorizedAccessException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.SetAclCommand
    Use of other functions like .GetAccessControl will result in a similar error: "Attempted to perform an unauthorized operation."
    How do you replace owner on all subcontainers and objects in Powershell with resorting to external applications like takeown, icacls, Windows Explorer GUI, etc.?
    Tony

    Hello,
    Last, here is the script I used to reset permissions on the "My Documents" tree structure that admins did not have access to:
    Example:  Powershell script to parse a directory of User-owned "My Document" redirection folders and reset permissions.
    #Script to Reset MyDocuments Folder permissions
    $domainName = ([ADSI]'').name
    Import-Module "PSCX" -ErrorAction Stop
    Set-Privilege (new-object Pscx.Interop.TokenPrivilege "SeRestorePrivilege", $true) #Necessary to set Owner Permissions
    Set-Privilege (new-object Pscx.Interop.TokenPrivilege "SeBackupPrivilege", $true) #Necessary to bypass Traverse Checking
    #Set-Privilege (new-object Pscx.Interop.TokenPrivilege "SeSecurityPrivilege", $true) #Optional if you want to manage auditing (SACL) on the objects
    Set-Privilege (new-object Pscx.Interop.TokenPrivilege "SeTakeOwnershipPrivilege", $true) #Necessary to override FilePermissions & take Ownership
    $Directorypath = "F:\Userpath" #locked user folders exist under here
    $LockedDirs = Get-ChildItem $Directorypath -force #get all of the locked directories.
    Foreach ($Locked in $LockedDirs) {
    Write-Host "Resetting Permissions for "$Locked.Fullname
    #######Take Ownership of the root directory
    $blankdirAcl = New-Object System.Security.AccessControl.DirectorySecurity
    $blankdirAcl.SetOwner([System.Security.Principal.NTAccount]'BUILTIN\Administrators')
    $Locked.SetAccessControl($blankdirAcl)
    ###################### Setup & apply correct folder permissions to the root user folder
    #Using recommendation from Ned Pyle's Ask Directory Services blog:
    #Automatic creation of user folders for home, roaming profile and redirected folders.
    $inherit = [system.security.accesscontrol.InheritanceFlags]"ContainerInherit, ObjectInherit"
    $propagation = [system.security.accesscontrol.PropagationFlags]"None"
    $fullrights = [System.Security.AccessControl.FileSystemRights]"FullControl"
    $allowrights = [System.Security.AccessControl.AccessControlType]"Allow"
    $DirACL = New-Object System.Security.AccessControl.DirectorySecurity
    #Administrators: Full Control
    $DirACL.AddAccessRule((new-object System.Security.AccessControl.FileSystemAccessRule("BUILTIN\Administrators",$fullrights, $inherit, $propagation, "Allow")))
    #System: Full Control
    $DirACL.AddAccessRule((new-object System.Security.AccessControl.FileSystemAccessRule("NT AUTHORITY\SYSTEM",$fullrights, $inherit, $propagation, "Allow")))
    #Creator Owner: Full Control
    $DirACL.AddAccessRule((new-object System.Security.AccessControl.FileSystemAccessRule("CREATOR OWNER",$fullrights, $inherit, $propagation, "Allow")))
    #Useraccount: Full Control (ideally I would error check the existance of the user account in AD)
    #$DirACL.AddAccessRule((new-object System.Security.AccessControl.FileSystemAccessRule("$domainName\$Locked.name",$fullrights, $inherit, $propagation, "Allow")))
    $DirACL.AddAccessRule((new-object System.Security.AccessControl.FileSystemAccessRule("$domainName\$Locked",$fullrights, $inherit, $propagation, "Allow")))
    #Remove Inheritance from the root user folder
    $DirACL.SetAccessRuleProtection($True, $False) #SetAccessRuleProtection(block inheritance?, copy parent ACLs?)
    #Set permissions on User Directory
    Set-Acl -aclObject $DirACL -path $Locked.Fullname
    Write-Host "commencer" -NoNewLine
    ##############Restore admin access & then restore file/folder inheritance on all subitems
    #create a template ACL with inheritance re-enabled; this will be stamped on each subitem to re-establish the file structure with inherited ACLs only.
    #$NewOwner = New-Object System.Security.Principal.NTAccount("$domainName","$Locked.name") #ideally I would error check this.
    $NewOwner = New-Object System.Security.Principal.NTAccount("$domainName","$Locked") #ideally I would error check this.
    $subFileACL = New-Object System.Security.AccessControl.FileSecurity
    $subDirACL = New-Object System.Security.AccessControl.DirectorySecurity
    $subFileACL.SetOwner($NewOwner)
    $subDirACL.SetOwner($NewOwner)
    ######## Enable inheritance ($False) and not copy of parent ACLs ($False)
    $subFileACL.SetAccessRuleProtection($False, $False) #SetAccessRuleProtection(block inheritance?, copy parent ACLs?)
    $subDirACL.SetAccessRuleProtection($False, $False) #SetAccessRuleProtection(block inheritance?, copy parent ACLs?)
    #####loop through subitems
    $subdirs = Get-ChildItem -path $Locked.Fullname -force -recurse #force is necessary to get hidden files/folders
    foreach ($subitem in $subdirs) {
    #take ownership to insure ability to change permissions
    #Then set desired ACL
    if ($subitem.Attributes -match "Directory") {
    # New, blank Directory ACL with only Owner set
    $blankdirAcl = New-Object System.Security.AccessControl.DirectorySecurity
    $blankdirAcl.SetOwner([System.Security.Principal.NTAccount]'BUILTIN\Administrators')
    #Use SetAccessControl to reset Owner; Set-Acl will not work.
    $subitem.SetAccessControl($blankdirAcl)
    #At this point, Administrators have the ability to change the directory permissions
    Set-Acl -aclObject $subDirACL -path $subitem.Fullname -ErrorAction Stop
    } Else {
    # New, blank File ACL with only Owner set
    $blankfileAcl = New-Object System.Security.AccessControl.FileSecurity
    $blankfileAcl.SetOwner([System.Security.Principal.NTAccount]'BUILTIN\Administrators')
    #Use SetAccessControl to reset Owner; Set-Acl will not work.
    $subitem.SetAccessControl($blankfileAcl)
    #At this point, Administrators have the ability to change the file permissions
    Set-Acl -aclObject $subFileACL -path $subitem.Fullname -ErrorAction Stop
    Write-Host "." -NoNewline
    Write-Host "fin."
    Write-Host "Script Complete."
    I hope you find this useful.
    Thank you,
    Tony
    Final Thought: There are great non-PS tools like
    Set-Acl and takeown which are external to PS & can also do the job wonderfully.  It may be much simpler to call those tools than recreate the wheel in pure
    code.  Feel free to use whatever best suits your time, scope & cost.

  • HT1789 How can you rename your iPod in iTunes 11?

    How can you rename your iPod in iTunes 11?
    I am using a Mac and an iPod Nano (the old longer one)

    Double-click the name in the device summary screen to get a cursor, and edit the name. In previous versions of iTunes, you could change the name by clicking it once.

  • HT1473 How do you rename files on a playlist within iTunes? Trying to rename some files from audio CD.  Thanks

    How do you rename files on a playlist in iTunes? Don't see a rename function and want to rename files coming in from audio CD as "track one."  Thanks

    Right-click the track, choose Get Info, and go to the Info tab.  Overtype the Name (and/or any other information that you want to change) with the new information.  Click OK when you are done.

  • How do you rename multiple files at the same time

    how do you rename multiple photo files with a name at the same time?

    This would be an excellent use of Automator. Here is a link to some instructions on how to do this using Automator.
    http://www.youtube.com/watch?v=Ie6zGxo2D-o
    If you don't like that then Google "Renmame multiple files Automator" and you will find many tutorials available.

  • How do you create or change excel spreadsheet downloaded from windows

    how do you create or change excel spreadsheet on macbook pro?

    Hi meadcm,
    You would need to have Excel installed on your Mac....
    You can get Office for Mac, which has Excel as a part of the package from Microsoft:
    http://www.microsoft.com/mac/buy
    Cheers,
    GB

  • How do you remove or change red border in Livecycle required

    How do you remove or change red border in Livecycle required field?
    When I make a field required, it makes the pdf show a thick ugly red border. How can I change that?

    Now you see me, now you don’t.
    Interactive forms highlight where you should enter data. To turn this highlighting on, click the Highlight Existing Fields button.
    The fillable fields within the form (see example below) are highlighted in a light blue color. This lets you enter information into these fields. By default, Adobe® Reader® displays a red border around required fields:
    Pretty dang ugly, huh?
    Fortunately, it can be turned off.  This script (placed on a form:ready event) will do the trick:
        if (xfa.host.name == "Acrobat")
    app.runtimeHighlight = false;
    Here’s how we achieve this:
    Part 1:
    In the Object palette, click the Value tab. Under Type, choose User Entered – Required.
    First, we need to define which fields are mandantory/required. Click within the desired field to select it.
    You can assign as many mandatory fields as the form requires. When you are finished doing this, enter the Script Editor.
              Note:   To show or hide the Script Editor window as you need it, click the toggle.
    Select the form:ready event. Be sure JavaScript is the chosen scripting language to run on the Client.
    Type the following script into the window:
        if (xfa.host.name == "Acrobat")
           app.runtimeHighlight = false;
    Save your work.
    Part 2:
    From the File menu, choose Form Properties.
    Click the Form Validation tab.
                   Click Color Failed Fields.
                   Check the box next to Color fields and fail their validations.
    To turn borders off, click the arrow next to Border Color, then click the box.
    To define a background color, click the arrow next to Background Color, the choose More Colors.
    Select the first available empty box, then click Define Custom Colors.
    Define a custom color per your visual identity guidelines.
    When you are finished, click on Add to Custom Colors, then click OK.
    Click OK on the Form Properties window.
    Save your work.
    The result? When the user tries to submit a form without first entering data into the required fields, an alert message is displayed.
    When the user clicks OK to clear the error message, form submission is cancelled.
    Failed fields are highlighted in an attractive way—without red borders.

  • Using the retouch tool, how do you make it change color? The old iPhoto one did, this one seems to be flesh-tone only, which is not how I need it to be. In old iPhoto, used the local color to blend, it was great.

    Using the retouch tool, how do you make it change color? The old iPhoto one did, this one seems to be flesh-tone only, which is not how I need it to be. In old iPhoto, used the local color to blend, it was great.

    I don't know which old version you're referring to but iPhoto 6's,  7's and 8's retouch tool works exactly the same as iPhoto 9's. The color of the enhance tool's area while applying is a light brown color but the retouch works on any color using the surrounding colors as a basis.
    During retouching:
    After retouching:
    OT

  • Tried the posted solution for the RETR problem and it works once then it returns. How do you make the change permanent?

    Tried the posted solution for the RETR problem and it works once then it returns. Once the email dl'ds the file deleted per the instructions returns. How do you make the change permanent?

    Hi DOC808HI
    # I don't know what you mean by "posted RETR solution". Could you please post a link to the suggested solution? Perhaps you are referring to this thread: https://support.mozilla.org/en-US/questions/991792 ?
    # Anyhow any further troubleshooting information you can provide will be great e.g. Your Operating System Version (XP, 7, Mac OS X Mavericks), your anti-virus if any, your mail provider, your ISP, what you did, what happened with exact error message, what happened
    Cheers!
    ...Roland

  • How do you rename the Windows drive in Mac?

    I have Windows loaded in BootCamp, but it appears in Mac as 'untitled'. How can I rename it to 'something_XP'?
    Many thanks for any help.  I am using Lion, highest updates, Bootcamp with Windows XP.  The drive on the HD (shared in an iMac 24") is actually named, but the name in Mac is 'untitled'.

    Yo Rename it in Windows; RightClick the C: drive object for Rename selection

  • How do you purge/compress/shrink the iPhoto11 folder/file size?

    How do you purge/compress/shrink the iPhoto11 folder/file size?
    I have been using iPhoto since iLife'05 and have always upgraded with each iteration of iLife. Without exception, I had just recently upgraded to iPhoto'11 when iLife'11 came out. Because I have used iPhoto to store all my photos and videos taken over the last 5 years or so, my iPhoto folder/file has become bigger and bigger over time and so I moved it to an external hard-drive. My main iPhoto'11 folder/file has 14,367 photos, 995 videos and is indicated to be 83 GB by iPhoto'11. But "Get Info" in Finder reports a whopping 130 GB.
    I started to think that this is getting a little crazy and I had wanted to better manage my photo collection, so I decided to "divide and conquer" this gigantic iPhoto'11 folder/file into several smaller, more manageable sized ones. So I made a duplicate copy of this gigantic iPhoto'11 folder/file onto another external hard-drive, fire-up iPhoto'11 again to delete away almost 80% of the photos and 90% of the videos. Now, my "slimmed-down" iPhoto folder/file has 3,000 photos, 75 videos and is indicated to be 6.8 GB by iPhoto'11. But despite the new "slimmed-down" status, the "Get Info" in Finder reports a still very huge 44 GB. Where did all those bulk come from? I have emptied both the iPhoto'11 Trash Can and Mac OS X Trash Can and these steps did not seemed to change anything at all.
    Therefore, I wanted to see what the "Get Info" in Finder will report if I were to delete 99.99% of the photos and video to leave just one (1) photo in iPhoto'11? Guess what is the result? My "One Photo experimental" iPhoto folder/file has 1 photo, 0 videos and is indicated to be 2 MB by iPhoto'11 yet the "Get Info" in Finder reports a mysterious 36.3 GB. There must be something hiding inside!
    Help! What can I do?

    I went on to try trashing away some of the folders and files inside and found that I could actually do it quite neatly if I go by the year which the photos are taken. After a lot of trial and error working on duplicate copy of my iPhoto '11 library, I am able to do away with all the clutter within the library and still open it normally.
    Now my 44GB obese iPhoto'11 library has been slimmed down to just a little over 7 GB (5 GB as reported by iPhoto'11) and I am just comfortable dealing with 2 GB of "don't-know-what-info" of clutter within the library.
    Remember my "One Photo Experimental" iPhoto'11 library that was 36.3 GB? I managed to bring it down to the realistic 22 MB size. This size is still double that of a brand new iPhoto'11 library I created to import 1 photo. However, it sure beat having 36.3 GB of clutter.
    So, now what I am gonna do is to "divide and conquer" the duplicate copies of my iPhoto'11 library into smaller sized ones according to their year. But I think I'll still keep the original bloated, gigantic 130 GB intact and continue to feed it with photos and videos until maybe it becomes 1 TB! Yikes!
    Anyway, million thanks for your tip and I really appreciate it! Have a Happy holidays!

  • How do you add a watermark to a protected file?

    How do you add a watermark to a protected file?

    Hi whobrew,
    Without the Document Permissions password, you won't be able to add a watermark to the PDF.
    Please let us know if you have additional questions.
    Best,
    Sara

  • How can you insert "Page Break" in a pdf file so you will specify the pages

    How can you insert "Page Break" in a pdf file so you will specify the pages

    How / from what was the PDF originally created?  It would be easiest to insert page breaks into the original document, then recreate the PDF.

  • How do you know the version of a JAR file ?

    how do you know the version of a JAR file ?
    is it what is written on MANIFEST.MF ?
    for example i have a JAR file
    whose MANIFEST.MF has this
    Manifest-Version: 1.0
    Created-By: Ant 1.4.1so, whats the version of this JAR ? 1.0 ?

    anyway, that was JSTL..jar.
    Now, come to another JAR file....
    whose MANIFEST.MF has......
    Manifest-Version: 1.0
    Created-By: Apache Ant 1.5.1
    Extension-Name: Struts Framework
    Specification-Title: Struts Framework
    Specification-Vendor: Apache Software Foundation
    Specification-Version: 1.1
    Implementation-Title: Struts Framework
    Implementation-Vendor: Apache Software Foundation
    Implementation-Vendor-Id: org.apache
    Implementation-Version: 1.1
    Class-Path:  commons-beanutils.jar commons-collections.jar commons-dig
    ester.jar commons-logging.jar commons-validator.jar jakarta-oro.jar s
    truts-legacy.jarso, How do you believe whats the version now ? do u go with the comment "Manifest-Version: 1.0" or "Specification-Version: 1.1" ?
    definitely, you would go with the "Specification-Version: 1.1" and declare this JAR as STRUTS 1.1
    hmmm, so, if nothing is mentioned like above should we follow the MANIFEST version as the JSTL version ? in my earlier example i did not find any comment on ""Specification-Version" ......so , if anybody gives me that JAR , how do i decide whether its 1.0 specification or 1.1 specifucation compliant ?
    can you tell whats the JSTL version of my earler example JAR file ?

Maybe you are looking for

  • I try to update my ipod touch but it keeps on saying it will delete my songs and stuff

    i try to update my ipod touch but it keeps on saying it will delete my songs and stuff

  • Can't sync mail with Yahoo mail

    I want to transfer my Yahoo contacts to Apple's mail program. I checked "synchronize with Yahoo" in my Address Book Preferences. I also went to Isync preferences and checked all there, including "enable syncing on my computer." The next thing I'm sup

  • How to get module wise custom objects

    Hi , How to get all the list of custom objects ( Eg : zreports, ztransactions, zscripts, zsmartforms,zwebdynpro components ..... ) and how to segregate them which module wise ( FI / MM / SD .... ) I am using Tadir for getting the custom objects. Plea

  • Edit/No-edit

    I have many input forms that have edit button. When the user wants to modify the data displayed he has to press edit button otherwise it will always be in no-edit mode. The problem is how to accomplish this. I am doing this currently is by use changi

  • Getting started ibooks pdf

    Is there a pdf for beginners on how to get started in selling ibooks. Im new here and cannot find a simple    What to do to get started. I have the pdf on apps. But after ten pages of how to sign in and make apps. No word whats needed for selling ibo