Sponsored Content
Top Forums Shell Programming and Scripting Sort/move files into folders and rename existing files. Post 303045396 by oatfoolery on Thursday 19th of March 2020 08:57:28 AM
Old 03-19-2020
Quote:
Originally Posted by RudiC
Again: too many escapes. Drop one of the two back slashes in the read delimiter's -d definition. Same for ALL the escaped double quotes around file and directory names downstream.


Sure your sophisticated regex to analyse $n works reliably? I'd prefer to determine the number length upfront, and then dissect $n.
You might want to provide a default valuein case $DST is undefined, to avoid creating directories in root.

Thanks so much for pointing that out, now it works beautifully Smilie
So far it has been reliable, but i will look into changing it your suggestion.
Thanks again!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Move files and rename ??

1. If I have a file-yyyymmdd.dat in a directory DATA1, then how do I move this file to directory DATA2 and the file name change to file-yyyymmdd.dat.currenttime I can manual do this $mv fileA-yyyymmdd.dat ./DATA2/fileA-yyyymmdd.dat.`date +%Y%m%d%H%M%S` but how do I move all of the files in... (1 Reply)
Discussion started by: sabercats
1 Replies

2. UNIX for Dummies Questions & Answers

Using Rename to move files

I am connecting to a remote server (Unix) and doing a ftp dowmload of files. The script (VB script) works fine except for not being able to move the downloaded files on the remote server to another folder. I need to move all files with an .asc extesnion from folder "tovecellio_edi" to folder... (1 Reply)
Discussion started by: snufse
1 Replies

3. UNIX for Dummies Questions & Answers

Move folders containing certain files

Hello, How can I move just the folders that contains files modified n days ago? Source tree: |-- SourceFolder | |-- Subfolder1 | | |-- file1.dat | | `-- file2.dat | |-- Subfolder2 | | |-- filea.dat | | `-- fileb.dat Destination tree: |-- ... (3 Replies)
Discussion started by: xavix
3 Replies

4. Shell Programming and Scripting

Move files to Folders

Hi Friends, Below is my requirement and i am not clear how to approach this issue in unix programming. I have a folder with 2500 files. The files are in below format. 1234_name1.txt 1234_name123.txt 4567_name1.txt 4567_name123.txt and i need a program which will read each file from this... (5 Replies)
Discussion started by: diva_thilak
5 Replies

5. UNIX for Dummies Questions & Answers

Rename files to indexnumber in multiple folders

I have multiple subfolders with multiple jpg I want the group of files in each subfolder renamed to their index number (3 digits) in the folder, so: folder/a.jpg = folder/001.jpg folder/b.jpg = folder/002.jpg folder/c.jpg = folder/003.jpg folder2/1.jpg = folder2/001.jpg folder2/2.jpg =... (2 Replies)
Discussion started by: cmanniche
2 Replies

6. Shell Programming and Scripting

Move all files but not folders to a new folder

Hi, I have a sub directory with a number of files and folders. What i want is a subdirectory with just folders and not files for cleanliness sake. So I want to move the files into the new folder but keep the folders in the same place. Move all files (but not folders) to new folder. I am... (4 Replies)
Discussion started by: Hopper_no1
4 Replies

7. Shell Programming and Scripting

How to move files to existing .tgz file?

Hi, I have already created the tar files. which consist of some log files and Audit.csv plz see the below code for that ================================================ tar -Pczf ARCH/${arc_date}.tgz $LOG/*.log $REYE/CEP/FiAdapter/Audit.${arc_date}.csv ... (3 Replies)
Discussion started by: pspriyanka
3 Replies

8. Shell Programming and Scripting

Moving files to folders and rename

Hello! I am new to this. I have many files from b_ap00 to b_ap80, and I need to move them to folder 00 to 80 respectively, where b_ap00 is in folder 00, b_ap01 is in folder 01. On top of this, I need to rename the file once they are inside the folder to b_ot, and subsequently run it (ifort -o... (8 Replies)
Discussion started by: krustytherusty
8 Replies

9. Shell Programming and Scripting

Move only folders and skipping files

How do I move all folders and its contents from a directory A to another directory B, skipping all files in Directory A ? ---------- Post updated at 12:53 PM ---------- Previous update was at 12:42 PM ---------- Ok. Got it. mv /A/*/ /B/ (1 Reply)
Discussion started by: DHeisenberg
1 Replies

10. Shell Programming and Scripting

SBATCH trinity for multiple files and rename/move the output files

Hey guys, I have wrote the following script to apply a module named "trinity" on my files. (it takes two input files and spit a trinity.fasta as output) #!/bin/bash -l #SBATCH -p node #SBATCH -A <projectID> #SBATCH -n 16 #SBATCH -t 7-00:00:00 #SBATCH --mem=128GB #SBATCH --mail-type=ALL... (1 Reply)
Discussion started by: @man
1 Replies
packingrules(4) 					     Kernel Interfaces Manual						   packingrules(4)

NAME
packingrules - packing rules file for cachefs DESCRIPTION
is a packing rules file for packingrules contains a list of directories and files that are to be packed. It also contains a list of direc- tories and files that are to be specifically excluded from packing. See cachefspack(1M). Many users choose to manually create the packing rules file and edit it by hand. Users can edit the packingrules (using any editor) to permanently change the packingrules file, or to gain access to more powerful options that are not available from the command line (such as the command). It is much easier to enter complex wildcard expressions by editing the packingrules file. Following is a description of the lines in a packing rules file. Blank lines and lines that begin with a pound sign are ignored. Lines can be continued by placing a backslash () immediately before the newline character. All other lines in the packingrules file have one of the following formats: This line identifies a directory (or pair of directories) under which files should be packed. At least one directory name must be specified. The arguments must be fully qualified path names and may include environment variables. This line enumerates a list of files and subdirectories beneath the current directory to be packed. This specification is recursive. That is, specifying the name of a directory automatically includes all files and subdirectories it contains. This line enumerates a list of files that are not to be packed. Regular expressions are permitted. There are important differences between the arguments to the and the statements. The arguments to statements can contain slashes and are interpreted as file names relative to the directories. The arguments to statements are simpler names or expressions that cannot contain slashes. An statement will not override a LIST statement. statements only exclude files that are found beneath listed directories. If the first name argument to a or an statement begins with an exclamation point the remainder of the statement will be executed as a com- mand that will be run in the current directory. The output of the command will be treated as a list of newline separated file names to be packed command) or to be excluded from the packing list command). For the command, the resulting file names will be interpreted relative to the enclosing directory. Blanks can be embedded in an argument by escaping them with a backslash () or enclosing the argument in double quotes (` " '). Double quotes can be passed in arguments by escaping the double quotes with a backslash (). lines only apply to the statement that precedes them. lines can appear before any statement (in which case they apply to all or after a statement (in which case they only apply to the that precedes them). Any number of these statements can occur in any combinations. The order is not important. EXAMPLES
The use of these statements is illustrated in the following packing rules file. # # Ignore junk files. # IGNORE core *.o *.bak *% # # Pack everything in the work subdirectory and in a few # favorite mailboxes. # BASE /net/bigserver/export/home/myname LIST work LIST m/incoming LIST m/action LIST m/pending # # Pack two important project directories but skip # all postscript output. # BASE /net/bigserver/export/projects $HOME/projects LIST poindexter epiphany IGNORE *.ps # # Pack the foonly package. # BASE /net/bigserver/opt/foonly /opt/foonly LIST !cat .packinglist # # Also pack the latest executables for the standard # build environment. # BASE /net/bigserver/export/buildenv $HOME/buildenv LIST !find . -type f -a -perm -111 -a -print AUTHOR
was developed by Sun Microsystems, Inc. SEE ALSO
cachefspack(1M). packingrules(4)
All times are GMT -4. The time now is 06:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy