ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Timestamps For Multiple Files In Directory Termial Macos
    카테고리 없음 2021. 1. 21. 17:05



    Create multiple folders from Terminal | 36 comments | Create New Account

    How To Change Created or Modified Timestamps for Files and Folders Martin Hendrikx Updated July 11, 2017, 10:34pm EDT Whether you need to hide your recent activity on a computer or if you need to synchronize file dates, using BulkFileChanger is the best way to adjust the creation, access, or modification dates and times of files or folders. Since macOS is a Unix-based system, nearly all system tasks you do every day with the help of its graphic interface can also be performed via the command line tool called Terminal. With regards to delete file or delete folder command line functionality, Terminal lets you. I have a directory that multiple users have access to. They change, upload, and delete files in the directory. They all belong to the same user group. The files in the directory have access rights of 660. The problem is that the users cannot set the modification time of files if they're not the owner of that file.

    Click here to return to the 'Create multiple folders from Terminal' hint
    The following comments are owned by whoever posted them. This site is not responsible for what they say.

    you might find it informative to do 'man xargs'.
    xargs is a core unix tool used to accomplish exactly what you are talking about, namely to take a list of data (command arguments) from a file and execute a certain command repeatedly. so in this case, for example, if you had a list of directory names in a file, one per line, you could use xargs to execute the mkdir command once for each line in the file.

    You can try this: if you have a list of names of new directories that you want to create--e.g., call it 'list':
    cat list | xargs mkdir -vp
    xargs will take the lines from its input [the output from cat], combine them into a single line and pass that line as additional arguments to the command specied as xargs' 1st argument--in this case, 'mkdir -vp'. If the resulting line would be too long [there IS an upper limit on the length of your argument string], xargs will invoke the command multiple times with segments of the list that 'fit'.
    As kircmc mentioned, be sure that the folder names in the list contain no spaces, or are enclosed in quotes, else you'll get one folder per word on the line.
    See the mkdir man page for info on the 'v' and 'p' options. Also, see the xargs man page for more info.

    it is possible to create multiple folders from a list in a file, you will just need to use an additional UNIX command, xargs. for example:
    % cat file_names
    folder1
    folder2
    folder3
    %cat file_names | xargs -i mkdir {}
    % ls | grep folder
    folder1
    folder2
    folder3
    %
    Note, this was tested on Solaris (don't have access to a mac right now), so the syntax might be slightly different. i'm not sure if the -i is necessary or not. also, i use tcsh, so the backslashes () escape the shell for the curly brackets ({}). depending on what shell you use, you may or may not need these.

    Another unix method of createing multiple folder is as follows:
    % mkdir long_folder_name_{00,01,02,03,04,05,06}
    this will creat the seven folders long_folder_name_ and ending in the expansion of the numbers in the array.

    Or you can execute mkdir `cat dirfile` where dirfile contains the names of the directories. Those are backquotes around the cat command.

    Most (all?) of the suggestions here require the directory names not to have spaces. The following command creates directory names with spaces. It requires that the directory names are listed in the file 'list', one per line:

    awk '{system('mkdir ' $0 '')}' list

    Have fun.

    Sorry, in the previous post some crucial backslashes vanished as a consequence of the html coding. Here I'll try again:
    awk '{system('mkdir ' $0 '')}' list

    Ah, but what if they have Double Quotes or Single Quotes in their names? How would one deal with that?

    To not care about spaces, quotes, etc, and the name of dirs is in folders.txt:

    and _that's_ why I love perl.

    perl, perl, what a nightmare. !!!! You should use and the utf8 accented etc chars are not welcome :(
    There's no need for the chomp if you use the lowercase L switch. There's no need for the parens, semicolon, or redirection either.

    Doesn't do a thing for me. Not even an error.
    ---
    --
    osxpounder

    I was referring to the first perl command, when I said it did nothing for me, but I'll add that the second perl command also did nothing. If I just run 'perl' on the command line, I see a process in Activity Monitor, so it's not that I lack perl.
    So far, the only commands in this thread that have worked for me are those of the original post, and then the xargs suggestion immediately following.
    ---
    --
    osxpounder

    Then something's fishy: I made a text file 'dirnames.txt' in my home directory with the contents
    one
    two
    three
    and then executed the above command in the same directory:
    perl -ne 'chomp($x=$_); mkdir($x);' < dirnames.txt
    Bingo: three folders, appropriately named.
    Cheers,
    Paul

    This one did nothing but gave me an error: 'Wilson Mug-Base.jpg: File name too long' Hmm. Is that because the file name had a space in it? I thought the point of the awk trick was that it would work with items that had spaces in their names.
    BTW, that's the last item in the list, the Wilson photo.
    ---
    --
    osxpounder

    The 'for' command is very nice for this:
    for item in `cat your_list.txt`; do mkdir /path/to/location/$item; done
    No text reformatting required.
    -systemsboy

    The 'for' command is very nice for this:

    for item in `cat your_list.txt`; do mkdir /path/to/location/$item; done

    No text reformatting required.

    This also fails for me. I get the error:

    mkdir: your_list.txt: File exists

    El Capitan Meadow, Yosemite National Park with kids: 'We caught the El Capitan Shuttle bus from in front of the Valley Visitor Center (Near shuttle stop 5) out to El Capitan meadow and Cathedral Beach. When the bus crossed the river we got off at stop E4. There we found a beautiful calm river w. Watch the last rays of sunset leave El Capitan, as you sit in El Cap Meadow. After entering the park, keep driving the loop until you get onto Northside Drive, and then park once you are right below El Capitan (the 3,000ft granite monolith that is very hard to miss). El Capitan is a majestic rock wall extending far into the sky above a beautiful lush green meadow. It is awe inspiring. The drive into Yosemite National park takes you through winding treed roads with amazing views along the way. El capitan meadow. Hotels near El Capitan Meadow, Yosemite National Park on Tripadvisor: Find 38,656 traveler reviews, 29,719 candid photos, and prices for 30 hotels near El Capitan Meadow in Yosemite National Park, CA. Apr 22, 2013  El Capitan: El Capitan Meadow - See 1,356 traveler reviews, 725 candid photos, and great deals for Yosemite National Park, CA, at Tripadvisor.

    ---
    --
    osxpounder

    Why not jot
    I had problems with the spaces.. It was impossible for me to include spaces in the name of the folders with this simple method.. any sugestion?
    I've always used for this. The sed command converts spaces to backslashed spaces, necessary to 'escape' each space and allow folder names with spaces.

    What criteria is used to determine which Unix commands are worthy to be posted as hints here?

    Silly me: you don't need the cat. This will do it, too: The for loop and backtick solutions don't work unless the folder names are separated by spaces on one line. Then again, you can't have multiple folders containing spaces that way, and it seems you'd never want to create any such folders.txt file like that anyway.
    Here's a way to do it that will create folders even if your list of names have spaces. The file dir_list.txt contains a list of directory names, one per line. Here goes:

    That should work for all files, spaces or not.

    Well, dangit, it didn't work for me. Maybe I goofed, but here's what I did:
    Created a plain text document in TextEdit, saved as plain text, UTF-8.
    In the same folder, I opened a Terminal, and used pico to create a text file that contained your script. I changed the name of the list.txt file to match mine.
    Saved out of pico to a file called 'do'. I chmoded 'do' 0700.
    Then I typed:
    ./do
    Nothing happened. No errors, no new folders.
    ---
    --
    osxpounder

    Timestamps For Multiple Files In Directory Terminal Macos Mac

    Do is a reserved word in bash. See the reserved words section in the bash man page. If you change the script name to anything else that's not a reserved bash word, it works.

    Timestamps for multiple files in directory terminal macos 7Thanks for the tip. I renamed it to 'herbie', but still, same results -- i.e, none, not even an error message.

    herbie's contents:

    cat list.txt | while read FILE

    do

    mkdir '${FILE}'

    done

    I'm using bash.

    Built for macOS. Google Drive for Mac: create, share and keep all your stuff in one place. You can now access your Google Drive files, even the big ones, from your Mac. Macos client for google drive. Map Google Drive as a network drive on macOS. Get access to your Google Drive accounts, manage documents with Commander One. This reliable Google Drive client for Mac provides easy access to all your cloud data. View, copy, delete your files with our Google Drive file manager.

    ---
    --
    osxpounder

    Try to print again.If the issue continues, contact us for further support. Hp laserjet cp1025 manual. Be sure to enter the correct password. Try this:Do the following steps to address the issue:. Enter your system OS login password when prompted.Note: The password you enter will not appear, which is normal. Enter sudo launchctl stop org.cups.cupsd Your screen will look similar to the following:Last login: Mon Nov 10 16:34:57 on consoleMacintosh: lindaterry$ sudo sh -c 'echo 'Sandboxing Relaxed' /etc/cups/cups-files.conf'Password:Sorry, try again.Password:Macintosh: lindaterry$ sudo launchctl stop org.cups.cupsdMacintosh: lindaterry$.

    Both uses of 'cat file | ..' in this thread are 'useless use of cat'. Google for that for details. In other words, sloppy coding, time to learn to clean up your messes.

    Bob: your kind offer of an Applescript was appreciated. It didn't compile for me, though. It breaks at the $ sign, saying 'Syntax error Expected end of line but found unknown token'.
    ---
    --
    osxpounder

    I thought I found a typo or two, so I changed Bob's script a bit, but still no results. I changed the quotes around $dir to single quotes, and that allowed the script to compile, but it did nothing. I saved it as an app and dropped a plain text file, with names, one per line, on it.
    I changed 'mdir' to 'mkdir', but that made no difference, either.
    ---
    --
    osxpounder

    This is my 3rd attempt at getting this Applescript posted cleanly. First I lost the < because it looked like the start of an html tag. The 2nd time I lost the 's and messed up the mkdir spelling. This time I'm just going to use Plain Old Text, and the heck with indentation and hope that line wrapping doesn't happen
    -- AppleScript wrapper to execute UNIX shell scripts with a drag and drop interface.
    -- Found basic script at http://MacOSXHints.com
    -- Modified to Create directories from a list stored one per line in a file dropped on the script
    -- script should handle spaces in name, apostrophes in names, etc..
    -- Bob Harris 25-Apr-2006
    on open filelist
    repeat with afile in filelist
    do shell script 'while read DIR;do mkdir -p '$DIR';done <' & quoted form of POSIX path of afile
    end repeat
    end open

    So as long as we're all posting various ways to do this, here is one that:
    • takes a list of directory (folder) names from a file, one per line
    • doesn't require any special escaping (no need for quotes)
    • doesn't have any problems with unicode
    Open TextEdit. Type the names of your folders one per line. Make sure there are no extra lines at the end of the files. Save this as, say 'names.txt' (make sure you've done 'Format -> Make Plain text' in TextEdit. Then in a terminal window: This assumes that TextEdit uses macroman encoding when you save as plain-text. It did for me. If you've got a UTF8 editor to create names.txt with, then you'd do this instead: I was unable to make Perl's mkdir work properly with unicode. And I don't know ruby well enough, though I'd be happy to see a ruby contribution.

    j.

    Ah, just realized you set the encoding in TextEdit when you save. In that case, select 'UTF-8' and just use: Oddly, if you re-open that that file TextEdit, it improperly decodes it as MacRoman. Oh well.

    Timestamps For Multiple Files In Directory Terminal Mac Os Disco Arreglar

    Okay, I win the award for replies to self. :-)
    TextEdit -> Preferences -> Open and Save -> Plain text file encoding.
    I had both opening/saving set to Automatic. Setting to UTF-8 does the right thing.
    j.

    If you use UTF-8 when saving in TextEdit, this perl invocation will work: :-)

    what, no ruby solution? ;-)

    One of the most basic computer functions — deleting files and folders — is also one of the most essential. If you never get rid of anything, soon enough all those extra gigabytes will take a toll on your Mac’s processing power, RAM, and hard drive, not to mention your digital life will resemble a dreadful episode of Hoarders.

    So deleting files is good and healthy. But how do you do that? Most people right-click on what they need gone and choose Move to Trash from the menu or use the File option in the menu bar. Others employ the ⌘ + Delete shortcut, which works across the system (even within dialog windows). Experts, however, often find themselves defaulting to the command line delete directory feature. Let’s see how and why you should learn it too.

    Why delete file command line feature is important

    Since macOS is a Unix-based system, nearly all system tasks you do every day with the help of its graphic interface can also be performed via the command line tool called Terminal.

    With regards to delete file or delete folder command line functionality, Terminal lets you:

    • Effortlessly erase one or multiple files, folders, and apps, bypassing any error messages you can get when you go the traditional route.
    • Remove files from Trash, including ones you can’t delete by simply emptying the trash.
    • Get rid of files that are invisible to you within Finder (usually system or root files, for example, .htaccess).
    • Delete files and folders in cases when Finder is unresponsive.

    Note: The Mac command line delete file feature is final and irreversible. While it lets you avoid any error messages, it also removes the files completely, without any possibility of retrieving them later on.

    How to use delete file command line feature

    Removing files from your Mac forever using Terminal is deceptively simple: just use the rm command followed by the name of the file. Here’s how it works in practice:

    Timestamps For Multiple Files In Directory Terminal Macos 10

    1. Launch Terminal from your Utilities folder in Applications.
    2. Check which directory you’re in by typing ls -la
    3. Then navigate down a directory with cd [directoryname] or up a directory with cd ./
    4. When you’re in the same directory as the file you want to delete, type rm [filename.extension]
    5. If you want to delete multiple files at once, list them all, but make sure there’s a space between each one.
    6. Press Enter to execute the command.

    Now all the files you specified after rm are gone for good. Navigate directories in your Mac and repeat the process as many times as you want.

    Surprised there was no confirmation before your files were deleted? Luckily there’s a way to add one as a safeguard for not deleting the wrong file by accident. Just use -i after the rm but before the first filename, like this: rm -i [filename.extension]. Terminal will then ask you whether you’re sure you want to delete the file. Reply y or yes followed by Enter and the file will be gone. This also works for multiple files, but you’ll have to confirm the removal of each one separately.

    How to make command line delete directory

    Surprisingly, you can’t delete a folder using the rm command because it has its own: rmdir.

    List Files In Directory

    Otherwise, rmdir works exactly the same as rm:

    1. Navigate to the appropriate directory using Terminal.
    2. Type rmdir [directoryname]
    3. Hit Enter.

    Sadly, you can’t use the -i hack when you’re deleting folders, so be extra careful! Sound packs for macos 9.

    Another thing to keep in mind is that rmdir only deletes the directory, but can’t delete any files or folders located within that directory.

    To delete a folder with everything in it, you need to use rm -r followed by the folder’s name. Using -i to create a warning here is possible and done like this: rm -ir [foldername].

    When it’s too difficult to find a folder or file via Terminal, but you can detect them in Finder, simply drag and drop the file onto the Terminal window to generate its path.

    Find and delete heavy folders in seconds

    Terminal commands are indispensable when you encounter stubborn files that just won’t go away, giving you all kinds of errors. But when you want to offload some space-hogging files and folders (including invisible ones) to release some much-needed Mac productivity and speed, you need to use an efficient app that can help you avoid manually navigating directories up and down.

    Timestamps For Multiple Files In Directory Terminal Macos Download

    Timestamps for multiple files in directory terminal macos download

    Timestamps For Multiple Files In Directory Terminal Macos 7

    CleanMyMac X is exactly what you need. It’s one of the best Mac optimization utilities in the world and contains a wealth of useful features, from streamlining your system files to scanning your Mac for viruses.

    However, what we’re looking for now specifically is the Space Lens feature:

    1. Launch CleanMyMac X (free download here).
    2. Navigate to Space Lens in the sidebar.
    3. Click Scan.
    4. The app will graphically show you which files or folders take up the most space in each directory. Navigate through them all and check the ones ready for deletion. When done, just hit Remove.

    By using Space Lens with CleanMyMac X, it’s easy to get rid of gigabytes of junk, and it all takes under a minute. Don’t forget to check back and repeat the process every month or so, and your Mac will keep performing at top speed for years to come.





Designed by Tistory.