My current path is /Users/UserName/Downloads/Downloaded_Path
. In Downloaded_Path
Folder i have multiple folders like F1
, F2
etc and each folder contain rar
part-files from rar
to r99
. What I want to do is to list all files which are either rar
or r*
extension type and copy them from those respective folder to a new folder.
MacOS – Listing/Moving certain files
bashmacosterminal
Related Question
- MacOS – Installing software on a MacBook
- MacOS – Recover certain files from Time machine from previous Mac
- Automator Action/Bash Script for selecting files from a list
- MacOS – How to wipe certain files from Time Machine Backups history but keep recent copies of them in case of a full restore
- MacOS – Show/emphasize only certain types of files in finder
- Sourcing and opening multiple files of same name, in specified folder, in Terminal? Is there a way
- Cp- copy a file in many folders, but only if it already exists there
- Transferring multiple files from one folder to another using Terminal
Best Answer
It's very easy to do,
The * acts as a wildcard so that we are copying every files that has .r in it ie 133.rar or 123.r99. The cp function more properly looks like this
Edit: upon re reading the question you will want to add the recursive tag -R
More specifically for you
Additionally what you can do to list all these files as well is
ls allows for some tags to give you more information about the files being listed. -a -l -t Or -alt all together. -a shows all files including the files starting with . Or .. -l lists the files in a long format -t lists them in time order (in which I believe is last touched or modified) The following code will explain more about the ls tags if you want to read more about it.
Another helpful tip is to get out of man within terminal, just press the q button.
Cheers!