{"_path":"/knowledge-base/terminal-bulk-actions","_draft":false,"_partial":false,"_empty":false,"title":"Terminal: Bulk Actions","description":"","excerpt":{"type":"root","children":[{"type":"element","tag":"h1","props":{"id":"terminal-bulk-actions"},"children":[{"type":"text","value":"Terminal: Bulk Actions"}]},{"type":"element","tag":"h2","props":{"id":"change-filenames"},"children":[{"type":"text","value":"Change Filenames"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Example:\nChange the string "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Bildschirmfoto"}]},{"type":"text","value":" to "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Screenshot"}]},{"type":"text","value":" in all filnames in the current dir."}]},{"type":"element","tag":"code","props":{"code":"for i in *Bildschirmfoto*.png; do [[ -e ${i/Bildschirmfoto/Screenshot} ]]\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"for i in *Bildschirmfoto*.png; do [[ -e ${i/Bildschirmfoto/Screenshot} ]]\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Alternative:"}]},{"type":"element","tag":"code","props":{"code":"mv \"$i\" \"${i/Bildschirmfoto/Screenshot}\"; done\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"mv \"$i\" \"${i/Bildschirmfoto/Screenshot}\"; done\n"}]}]}]},{"type":"element","tag":"h2","props":{"id":"download-files-with-curl"},"children":[{"type":"text","value":"Download files with curl"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Download several files with curl:"}]},{"type":"element","tag":"code","props":{"code":"curl -O https://domain.com/image.jpg\ncurl -O https://domain.com/image2.jpg\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"curl -O https://domain.com/image.jpg\ncurl -O https://domain.com/image2.jpg\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Search folder (and subfolders) for a specific file type (e.g. "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"jpg"}]},{"type":"text","value":", "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"jpeg"}]},{"type":"text","value":" or "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"png"}]},{"type":"text","value":") and copy the files to another folder:"}]},{"type":"element","tag":"code","props":{"code":"find 'path/to/folder' -type f -name \"*png\" -exec cp {} 'path/to/another/folder' \\;\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"find 'path/to/folder' -type f -name \"*png\" -exec cp {} 'path/to/another/folder' \\;\n"}]}]}]},{"type":"element","tag":"h2","props":{"id":"create-folders-from-txt-file"},"children":[{"type":"text","value":"Create folders from .txt file"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Create a "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"folders.txt"}]},{"type":"text","value":" file with folder names (no blank spaces!) in seperate lines:"}]},{"type":"element","tag":"code","props":{"code":"Folder-01\nFolder-02\nAnother-Folder\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"Folder-01\nFolder-02\nAnother-Folder\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Open terminal and "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"cd"}]},{"type":"text","value":" to dir with the "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"folders.txt"}]},{"type":"text","value":" file (i.e. the Desktop)"}]},{"type":"element","tag":"code","props":{"code":"cd /Users/username/Desktop\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"cd /Users/username/Desktop\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"then run"}]},{"type":"element","tag":"code","props":{"code":"cat folders.txt | xargs mkdir\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"cat folders.txt | xargs mkdir\n"}]}]}]}]},"public":true,"body":{"type":"root","children":[{"type":"element","tag":"h1","props":{"id":"terminal-bulk-actions"},"children":[{"type":"text","value":"Terminal: Bulk Actions"}]},{"type":"element","tag":"h2","props":{"id":"change-filenames"},"children":[{"type":"text","value":"Change Filenames"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Example:\nChange the string "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Bildschirmfoto"}]},{"type":"text","value":" to "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Screenshot"}]},{"type":"text","value":" in all filnames in the current dir."}]},{"type":"element","tag":"code","props":{"code":"for i in *Bildschirmfoto*.png; do [[ -e ${i/Bildschirmfoto/Screenshot} ]]\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#FF7B72"}},"children":[{"type":"text","value":"for"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":" i "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF7B72"}},"children":[{"type":"text","value":"in"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF7B72"}},"children":[{"type":"text","value":"*"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"Bildschirmfoto"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF7B72"}},"children":[{"type":"text","value":"*"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":".png"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF7B72"}},"children":[{"type":"text","value":";"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF7B72"}},"children":[{"type":"text","value":"do"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":" [[ "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF7B72"}},"children":[{"type":"text","value":"-e"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":" ${i"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF7B72"}},"children":[{"type":"text","value":"/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"Bildschirmfoto"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF7B72"}},"children":[{"type":"text","value":"/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"Screenshot} ]]"}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Alternative:"}]},{"type":"element","tag":"code","props":{"code":"mv \"$i\" \"${i/Bildschirmfoto/Screenshot}\"; done\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"mv "}]},{"type":"element","tag":"span","props":{"style":{"color":"#A5D6FF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"$i"}]},{"type":"element","tag":"span","props":{"style":{"color":"#A5D6FF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#A5D6FF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"${i"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF7B72"}},"children":[{"type":"text","value":"/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"Bildschirmfoto"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF7B72"}},"children":[{"type":"text","value":"/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"Screenshot}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#A5D6FF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF7B72"}},"children":[{"type":"text","value":";"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF7B72"}},"children":[{"type":"text","value":"done"}]}]}]}]}]},{"type":"element","tag":"h2","props":{"id":"download-files-with-curl"},"children":[{"type":"text","value":"Download files with curl"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Download several files with curl:"}]},{"type":"element","tag":"code","props":{"code":"curl -O https://domain.com/image.jpg\ncurl -O https://domain.com/image2.jpg\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"curl -O https://domain.com/image.jpg"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"curl -O https://domain.com/image2.jpg"}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Search folder (and subfolders) for a specific file type (e.g. "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"jpg"}]},{"type":"text","value":", "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"jpeg"}]},{"type":"text","value":" or "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"png"}]},{"type":"text","value":") and copy the files to another folder:"}]},{"type":"element","tag":"code","props":{"code":"find 'path/to/folder' -type f -name \"*png\" -exec cp {} 'path/to/another/folder' \\;\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"find "}]},{"type":"element","tag":"span","props":{"style":{"color":"#A5D6FF"}},"children":[{"type":"text","value":"'path/to/folder'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":" -type f -name "}]},{"type":"element","tag":"span","props":{"style":{"color":"#A5D6FF"}},"children":[{"type":"text","value":"\"*png\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":" -exec cp {} "}]},{"type":"element","tag":"span","props":{"style":{"color":"#A5D6FF"}},"children":[{"type":"text","value":"'path/to/another/folder'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#79C0FF"}},"children":[{"type":"text","value":"\\;"}]}]}]}]}]},{"type":"element","tag":"h2","props":{"id":"create-folders-from-txt-file"},"children":[{"type":"text","value":"Create folders from .txt file"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Create a "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"folders.txt"}]},{"type":"text","value":" file with folder names (no blank spaces!) in seperate lines:"}]},{"type":"element","tag":"code","props":{"code":"Folder-01\nFolder-02\nAnother-Folder\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"Folder-01"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"Folder-02"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"Another-Folder"}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Open terminal and "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"cd"}]},{"type":"text","value":" to dir with the "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"folders.txt"}]},{"type":"text","value":" file (i.e. the Desktop)"}]},{"type":"element","tag":"code","props":{"code":"cd /Users/username/Desktop\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#79C0FF"}},"children":[{"type":"text","value":"cd"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":" /Users/username/Desktop"}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"then run"}]},{"type":"element","tag":"code","props":{"code":"cat folders.txt | xargs mkdir\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"cat folders.txt "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF7B72"}},"children":[{"type":"text","value":"|"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":" xargs mkdir"}]}]}]}]}]}],"toc":{"title":"","searchDepth":2,"depth":2,"links":[{"id":"change-filenames","depth":2,"text":"Change Filenames"},{"id":"download-files-with-curl","depth":2,"text":"Download files with curl"},{"id":"create-folders-from-txt-file","depth":2,"text":"Create folders from .txt file"}]}},"_type":"markdown","_id":"content:04.knowledge-base:terminal-bulk-actions.md","_source":"content","_file":"04.knowledge-base/terminal-bulk-actions.md","_extension":"md"}