Sponsored Content
Top Forums Shell Programming and Scripting read list of filenames from text file and remove these files in multiple directories Post 302110135 by cfajohnson on Saturday 10th of March 2007 12:35:40 PM
Old 03-10-2007
Quote:
Originally Posted by fxvisions
I have a large list of filenames from an Excel sheet, which I then translate into a simple text file. I'd like to use this list, which contains various file extensions ,

Does the file contain file names or file extensions?
Quote:
to archive these files and then remove them recursively through multiple directories and subdirectories. So far, it looks like a combination of find, pipe, and xargs may work, but would like to consult some gurus.

The best method will depend on the format of the file, the sanity of the filenames, etc.

The best way might be to move the files to another directory, then use whatever archiving method you like on that directory.

This code will retain the directory structure in the archive directory, so that multiple files of the same name can be accommodated:
Code:
archivedir=$HOME/arc
[ -d "$archivedir" ] || mkdir -p "$archivedir" || exit 1
while IFS= read -r file
do
  find . -name "$file" |
    while IFS= read -r f
    do
      dir=$archivedir/${f%/*}
      [ -d "$dir" ] || mkdir -p "$archivedir" || continue
      mv "$f" "$dir"
    done
done < FILE_WITH_LIST

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

read list of filenames from text file, archive, and remove

I posted a week ago regarding this scripting question, but I need to revisit and have a few more questions answered.. User cfajohnson was extremely helpful with the archive script, but clarification on my part is needed to help steer the answer in a direction that works in this particular... (5 Replies)
Discussion started by: fxvisions
5 Replies

2. Shell Programming and Scripting

a remove script taken in input a file which contain a list of directories

Hi, I'm looking to delete some files from directories. I've just put in a file the location of these files. e.g: in file supprs.txt there is: /usr/host/t1.txt /etc/dev/u1.java /home/new/files/view.c Is it possible to take this file "supprs.txt" as a parameter in a shell command ? (2 Replies)
Discussion started by: yeclota
2 Replies

3. Shell Programming and Scripting

Remove Duplicate Filenames in 2 very large directories

Hello Gurus, O/S RHEL4 I have a requirement to compare two linux based directories for duplicate filenames and remove them. These directories are close to 2 TB each. I have tried running a: Prompt>diff -r data1/ data2/ I have tried this as well: jason@jason-desktop:~$ cat script.sh ... (7 Replies)
Discussion started by: jaysunn
7 Replies

4. Shell Programming and Scripting

Remove filenames beginning with multiple dots

hi all, I want to remove filenames beginning with multiple dots.how I can do this. Thanks in advance (5 Replies)
Discussion started by: sriharsharavi
5 Replies

5. Shell Programming and Scripting

Remove files from subdirectories given a list of filenames

Dear all, I have a dir structure like main_dir At_nn Ag_js Nf_hc .... mcd32 mgd43... mcd32 mgd43... mcd32 mgd43... and each subdir (e.g. mcd32, mgd43) contains files. Now, i... (15 Replies)
Discussion started by: yogeshkumkar
15 Replies

6. UNIX for Advanced & Expert Users

ls -ltr a list of filenames-with-spaces within a text file

OS: RHEL 5.8 shell: bash 3.2.25 Directory /home/guest/ contains these files: file a file b file c fileD fileE fileF testFile.txt I'm trying to find the syntax to run ls -ltr against this list of files that is contained within a text file, testFile.txt. The file testFile.txt has... (4 Replies)
Discussion started by: uschaafm
4 Replies

7. Shell Programming and Scripting

There are multiple filenames in the directory.How to return the the lastest files for each file name

there are mutiple file nams in the directory. How to return the the lastest files for each file name. ex. abc1234_050201 abc1234_050206 abc1234_050208 xyz34_050204 xyz34_050210 xyz34_050218 thanks (4 Replies)
Discussion started by: grand_sam
4 Replies

8. Shell Programming and Scripting

Read multiple text files and copy data to csv

hi i need to extract lines from multiple files to a csv file. for example, i have these 3 files file1.txt date:29dec1980 caller:91245824255 called:8127766 file2.txt date:11apr2014 caller:9155584558 called:8115478 file3.txt date:25jun2015 caller:445225552 called:8117485 (30 Replies)
Discussion started by: lp.descamps
30 Replies

9. UNIX for Beginners Questions & Answers

awk GSUB read field values from multiple text files

My program run without error. The problem I am having. The program isn't outputting field values with the column headers to file.txt. Each of the column headers in file.txt has no data. MEMSIZE SECOND SASFoundation Filename The output results in file.txt should show: ... (1 Reply)
Discussion started by: dellanicholson
1 Replies

10. UNIX for Beginners Questions & Answers

How do I custom sort the files in a directory using the filenames in a text file.?

Hi all, (5 Replies)
Discussion started by: KMusunuru
5 Replies
Excel::Template::Element::Cell(3pm)			User Contributed Perl Documentation		       Excel::Template::Element::Cell(3pm)

NAME
Excel::Template::Element::Cell - Excel::Template::Element::Cell PURPOSE
To actually write stuff to the worksheet NODE NAME
CELL INHERITANCE
ELEMENT ATTRIBUTES
o TEXT This is the text to write to the cell. This can either be text or a parameter with a dollar-sign in front of the parameter name. o COL Optionally, you can specify which column you want this cell to be in. It can be either a number (zero-based) or an offset. See Excel::Template for more info on offset-based numbering. o REF Adds the current cell to the a list of cells that can be backreferenced. This is useful when the current cell needs to be referenced by a formula. See BACKREF and RANGE. o WIDTH Sets the width of the column the cell is in. The last setting for a given column will win out. o TYPE This allows you to specify what write_*() method will be used. The default is to call write() and let Spreadsheet::WriteExcel make the right call. However, you may wish to override it. Excel::Template will not do any form of validation on what you provide. You are assumed to know what you're doing. The legal types (taken from Spreadsheet::WriteExcel) are: o COMMENT Add a comment to the cell o blank o formula o number o string o url o date_time other write_* methods as defined defined Spreadsheet::WriteExcel would be integrated by request CHILDREN
FORMULA EFFECTS
This will consume one column in the current row. DEPENDENCIES
None USAGE
<cell text="Some Text Here"/> <cell>Some other text here</cell> <cell text="$Param2"/> <cell>Some <var name="Param"> text here</cell> In the above example, four cells are written out. The first two have text hard-coded. The second two have variables. The third and fourth items have another thing that should be noted. If you have text where you want a variable in the middle, you have to use the latter form. Variables within parameters are the entire parameter's value. Please see Spreadsheet::WriteExcel for what constitutes a legal formula. AUTHOR
Rob Kinyon (rob.kinyon@gmail.com) SEE ALSO
ROW, VAR, FORMULA perl v5.14.2 2012-04-29 Excel::Template::Element::Cell(3pm)
All times are GMT -4. The time now is 05:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy