Mac OS10.6.8 - A way of deleting or removing files from a folder, using a list of file names? - osx-snow-leopard

I have a folder with 2508 files (jpg and pdf) in it on my drive. I have a list in a .txt file of about 1000 files which I want to remove from that folder - either by deleting to trash, or removing to another folder.
Is there a utility - or possibly commands I can put into the terminal - which I can use to do this, without manually moving files while looking through my list?
(Context: The list is a list of orphaned image files put out by Dreamweaver - which I want to remove from the images folder of a given site)..
Any help appreciated.
Thanks.

Put this in the terminal:
cat filename-of-list-with-files | xargs rm

Related

How do I get previous directories and folders using PuTTY?

I created a directory root/, folder /temp and change it with emacs folder, and then add a file quote_dora. I want to add a text file to quote_dora.
I have figured it out already.
Runs emacs quote_dora
write text on quote_dora file
ctl-x and ctl-c to save and exist.

How to unzip files that are in individual folders?

I own a MacBook Air. I'm trying to unzip all of these folders all at once instead of double clicking on each zip file that are in each directory. Is it possible? If so, how? For example, Folder 1 contains Cow.zip and Pig.zip, Folder 2 contains Dragon.zip, Dog.zip, and Cat.zip and
Folder 3 contains Hen.zip and Flowers.zip. Folder 1, Folder 2, and Folder 3, are in File called Animals.
Try this:
open ./*/*.zip
This will recursively traverse all the folders in the current directory and open all .zip files (i.e. "double click"/unzip).
If you need to unzip lots of files, use this command instead to avoid numerous pop ups. (Replace path/to/folder with the path that contains the folders with zips/more folders)
find path/to/folder -name "*.zip" | while read filename; do unzip -o -d "`dirname "$filename"`" "$filename"; done;

Batch script to zip a folder using InfoZip

i'm a near complete beginner to batch scripting.
I'm currently learning how to create batch files. My goal is to compress a folder using exclusively InfoZip, add the date to the file name, and have that file copied to an USB memory stick plugged on H:\
The reason why i need to use InfoZip, even though it is a very old program, is because i need somthing that works even on Win95.
InfoZip is not installed, it is just unpacked in folder and ready to use.
It is possible to download InfoZip 3.0 from here:
https://sourceforge.net/projects/infozip/
Anyway, so far, the only thing i could come up with is this...
--------------------------------------
Title : Your folder will be zipped into an archive that will be copied on the USB memory stick plugged on your computer. Please DO NOT remove the memory stick during the operation.
#ECHO OFF
call d:\infozip\wiz.exe
pause
--------------------------------------
It just brings up the InfoZip window on the screen, but then i have absolutely no idea about how to make it zip a folder, add the date, and copy that zipped file to the USB.
All the regular commands meant for 7-zip or Winzip don't seem to work with InfoZip.
I could really use some help, please :)
Thanks!
Using the waybackmachine I was able to get the documentation for info-zip:
https://web.archive.org/web/20170829173722/http://www.info-zip.org/mans/zip.html#EXAMPLES
In contrary to what zip.exe shows, the syntax for zipping files is this:
zip -r zipfilename zipfilecontents
Example:
zip -r myzip.zip c:\myfolder\*.*
The -r parameter includes subfolders as well.
Problem is that the complete folder structure is included in the zip. I have not found a solution for this yet.
To solve the structure folder problem, add a cd command that will target the folder container which has inside your file or files. This before running the code proposed by Martien de Jong upside.
for example:
The path of my file is: cd C:\aa\B\file.txt
So the path you will put in the cd to target the folder container is: cd C:\aa\B
cd C:\aa\B
zip -r myzip.zip B\*.*
*Remember that this code will zip all the files included in B folder.

IBM i PASE tar - Excluding files or directories

I want to exclude some directories from an archive using the PASE tar command on an IBMi but the [-X Exclude File] option doesn't seems to work for me.
I tried using an exclude file that just contained a file name (/home/JSMITH/data/sub2/file2.txt) and then one that just contained a pattern (*.txt), and neither archive operation omitted anything.
Given the following directory structure:
/home/JSMITH/data
/home/JSMITH/data/sub1
/home/JSMITH/data/sub1/file1.txt
/home/JSMITH/data/sub2
/home/JSMITH/data/sub2/file2.txt
/home/JSMITH/data/sub3
/home/JSMITH/data/sub3/file3.txt
and the following command:
/qopensys/usr/bin/tar -cvf /home/JSMITH/test.tar -X /home/JSMITH/excludes.txt /home/JSMITH/data
The entire /home/JSMITH/data structure gets included in the resulting archive.
I have tried using the /home/JSMITH/excludes.txt file with either of these contents:
/home/JSMITH/data/sub2/file2.txt
or
*.txt
How does one exclude files/directories/patterns from the IBMi PASE tar command?
You need the full path in the exclude file.
I created mine via ls /home/JSMITH/data/*.txt > /home/JSMITH/excludes.txt
If you're doing it by hand, make certain you haven't got any trailing whitespace.
Also, I used Notepad++ when I created mine by hand. I found that the green screen edtf created an EBCDIC file with CRLF in it, and that didn't exclude for me.
IBM i 7.1

Moving/Grouping Files Unix

I have one folder with about 1000 files and I want to group them according to their resepctive parent folders.
I did ls- R > updated.txt to get the original setup of folders and files.
The updated. txt looks like this:
./Rhodococcus_RHA1:
NC_008268.fna
NC_008269.fna
NC_008270.fna
NC_008271.fna
./Rhodoferax_ferrireducens_T118:
NC_007901.fna
NC_007908.fna
./Rhodopseudomonas_palustris_BisA53:
NC_008435.fna
./Rhodopseudomonas_palustris_BisB18:
NC_007925.fna
./Rhodopseudomonas_palustris_BisB5:
NC_007958.fna
./Rhodopseudomonas_palustris_CGA009:
NC_005296.fna
NC_005297.fna
So, by looking at this file, I know what files go into what folder. The folder with all the 1000 files together looks like this:
results_NC_004193.fna.1.ebwt.map
results_NC_004307.fna.1.ebwt.map
results_NC_004310.fna.1.ebwt.map
results_NC_004311.fna.1.ebwt.map
results_NC_004337.fna.1.ebwt.map
results_NC_004342.fna.1.ebwt.map
results_NC_004343.fna.1.ebwt.map
results_NC_004344.fna.1.ebwt.map
and so on...
You can see that the filenames of all the 1000 files are dependent on their original names in the folder setup(if that's a good way to explain it).
I want to move these results_XXXXXXXX files to folders (have to create new folders) with the original setup. So it should be something like this:
./Rhodococcus_RHA1: (this is a folder)
results_NC_008268.fna.1.ebwt.map
results_NC_008269.fna.1.ebwt.map
results_NC_008270.fna.1.ebwt.map
results_NC_008271.fna.1.ebwt.map
./Rhodoferax_ferrireducens_T118:
results_NC_007901.fna.1.ebwt.map
results_NC_007908.fna.1.ebwt.map
I don't really know how to do this... maybe some kind of mov command? I'd appreciate help with this problem.
Run the following command from the folder where you have those 1000 files. The path/to/original/files is the path to the original files (the one that you did ls -R). you should get a list of mv commands. Verify several of them to confirm that those are correct. If so, add | sh next the command and rerun it to execute those commands. If you don't have all the corresponding files in the 1000 files folder, you would get mv commands that would return "file not found", that can be ignored or piped to /dev/null. This assumes that you always have a file in original folder so that it knows where to move the file. If not, some of those 1000 files won't be moved. As always, take a good backup before you do this.
find path/to/original/files -type f | awk -F"/" '{ path=$0; sub($NF, "", path); printf("mv results_%s.1.ebwt.map \"%s\"\n", $NF, path);}'

Resources