08-03-2009
Rename a lot of files using shells script
Hi
This is the list file that i have :
Quote:
[~/CDR/CSV-FREE-partition-1/20090601]$ ls -la | head -15
total 102
drwxr-xr-x+ 2 Administrators ???????? 0 Aug 3 11:46 ./
drwxr-xr-x+ 28 eindwib mkgroup-l-d 0 Aug 3 11:53 ../
-rwxr-xr-x 1 Administrators ???????? 857 Aug 3 11:46 udr-FREE-SASN-DST-MASTER-R6-partition-1-200906010011+0800-31533.csv.bz2*
-rwxr-xr-x 1 Administrators ???????? 911 Aug 3 11:46 udr-FREE-SASN-DST-MASTER-R6-partition-1-200906010028+0800-31534.csv.bz2*
-rwxr-xr-x 1 Administrators ???????? 588 Aug 3 11:46 udr-FREE-SASN-DST-MASTER-R6-partition-1-200906010043+0800-31535.csv.bz2*
-rwxr-xr-x 1 Administrators ???????? 451 Aug 3 11:46 udr-FREE-SASN-DST-MASTER-R6-partition-1-200906010059+0800-31536.csv.bz2*
-rwxr-xr-x 1 Administrators ???????? 326 Aug 3 11:46 udr-FREE-SASN-DST-MASTER-R6-partition-1-200906010115+0800-31537.csv.bz2*
-rwxr-xr-x 1 Administrators ???????? 422 Aug 3 11:46 udr-FREE-SASN-DST-MASTER-R6-partition-1-200906010135+0800-31538.csv.bz2*
-rwxr-xr-x 1 Administrators ???????? 442 Aug 3 11:46 udr-FREE-SASN-DST-MASTER-R6-partition-1-200906010150+0800-31539.csv.bz2*
-rwxr-xr-x 1 Administrators ???????? 490 Aug 3 11:46 udr-FREE-SASN-DST-MASTER-R6-partition-1-200906010205+0800-31540.csv.bz2*
-rwxr-xr-x 1 Administrators ???????? 299 Aug 3 11:46 udr-FREE-SASN-DST-MASTER-R6-partition-1-200906010225+0800-31541.csv.bz2*
-rwxr-xr-x 1 Administrators ???????? 300 Aug 3 11:46 udr-FREE-SASN-DST-MASTER-R6-partition-1-200906010240+0800-31542.csv.bz2*
-rwxr-xr-x 1 Administrators ???????? 299 Aug 3 11:46 udr-FREE-SASN-DST-MASTER-R6-partition-1-200906010255+0800-31543.csv.bz2*
-rwxr-xr-x 1 Administrators ???????? 301 Aug 3 11:46 udr-FREE-SASN-DST-MASTER-R6-partition-1-200906010310+0800-31544.csv.bz2*
The files is more than this.
I will rename one by one file become like this :
Quote:
udr-FREE-SASN-DST-MASTER-R6-partition-1-200905010011+0800-31533.csv.bz2*
udr-FREE-SASN-DST-MASTER-R6-partition-1-200905010028+0800-31534.csv.bz2*
udr-FREE-SASN-DST-MASTER-R6-partition-1-200905010043+0800-31535.csv.bz2*
udr-FREE-SASN-DST-MASTER-R6-partition-1-200905010059+0800-31536.csv.bz2*
udr-FREE-SASN-DST-MASTER-R6-partition-1-200905010115+0800-31537.csv.bz2*
udr-FREE-SASN-DST-MASTER-R6-partition-1-200905010135+0800-31538.csv.bz2*
udr-FREE-SASN-DST-MASTER-R6-partition-1-200905010150+0800-31539.csv.bz2*
udr-FREE-SASN-DST-MASTER-R6-partition-1-200905010205+0800-31540.csv.bz2*
udr-FREE-SASN-DST-MASTER-R6-partition-1-200905010225+0800-31541.csv.bz2*
udr-FREE-SASN-DST-MASTER-R6-partition-1-200905010240+0800-31542.csv.bz2*
udr-FREE-SASN-DST-MASTER-R6-partition-1-200905010255+0800-31543.csv.bz2*
udr-FREE-SASN-DST-MASTER-R6-partition-1-200905010310+0800-31544.csv.bz2*
So just change the time stamp 200906 become 200905.
Is it possible using script ?
Thanks
10 More Discussions You Might Find Interesting
1. OS X (Apple)
Hi All !!!
Is there any solution to get rid of / " * in old files names WITH A SCRIPT
(About 100 Gb of old files)
I know it can be done i just dont know how !
Hope that some one can help
Best R.
Yovel (1 Reply)
Discussion started by: yoveln
1 Replies
2. UNIX for Dummies Questions & Answers
Have files of the sort 3p1522015.dgn and need to have them renamed to 152201.dgn. Essentially dropping the 1st 2 characters and the last. I'm relatively new to UNIX and uncertain of where to start. I hope this provides enough detail.
Thanks (5 Replies)
Discussion started by: Dinkster
5 Replies
3. Shell Programming and Scripting
here I go again...kinda hard to explain so I apologize.
I need to rename a bunch of files in a directory. I need to remove the first three characters of the filename, and then toward the end of the filename there is constant text inside of brackets. here is a demo (not for real) 'ls -1' of the... (11 Replies)
Discussion started by: ajp7701
11 Replies
4. Shell Programming and Scripting
Let me preface this by stating I have absolutely no idea what I'm doing in this arena, but I'm in need of a little help here.
I need to take filenames like this: amwed_0402c-slug~1-cp.jpg
And reduce them to slug~1.jpg
That is, I need to remove the first 12 and last 3 characters. The... (3 Replies)
Discussion started by: cpreovol
3 Replies
5. UNIX for Dummies Questions & Answers
I wrote a simple script that converts my windows text files to unix, so that I can compare them to different unix files purposes of my project.
win2unix file1.txt file1Win.txt
win2unix file2.txt file2Win.txt
etc
Is there a way to simplify this to:
<while .txt in... (5 Replies)
Discussion started by: idano530
5 Replies
6. Shell Programming and Scripting
Hello,
I have this problem.
In a directory I have 4 csv files with this format:
PHOENIX_KM_INTERAZIONI_YYYYMMDD.csv
PHOENIX_KM_TRIPLETTE_YYYYMMDD.csv
NEWCAB_KM_INTERAZIONI_YYYYMMDD.csv
NEWCAB_KM_INTERAZIONI_YYYY_MM_DD.csv
YYYYMMDD: format CURRENT date
I wont rename all files in... (4 Replies)
Discussion started by: manichino74
4 Replies
7. Shell Programming and Scripting
Hi All,
I want to write a script to rename the file in to the incremental order
for example
Original file
filename=/nfs/n1/file1.img
filename=/nfs/n1/file1.img
filename=/nfs/n1/file1.img
filename=/nfs/n1/file1.img
filename=/nfs/n1/file1.img
I want output shpuld be... (4 Replies)
Discussion started by: mangeshpardhi
4 Replies
8. Shell Programming and Scripting
Hi all,
I have a many folders with zipped files in them. The zipped files are txt files from different folders. The txt files have the same names. If i try to
find . -type f -name "*.zip" -exec cp -R {} /myhome/ZIP \; it fails since the ZIP files from different folders have the same names and... (2 Replies)
Discussion started by: pmkenya
2 Replies
9. Shell Programming and Scripting
I have a lot number audio files in the MP3 proprietary format, I want to convert them to 'opus' the free and higher quality format, with keep metadata also.
My selection command-line programs are SoX (Sound eXchange) for convert MP3 files to 'AIFF' format in order to keep quality and metadata*... (1 Reply)
Discussion started by: temp-usr
1 Replies
10. Shell Programming and Scripting
Hello friends!
I have a problem with my script. I'm a italian boy. Sorry for my english ehehehehehhe.
I've many files .jpg and I would like rename they in this mode:
I have not files with progressive number e I would like rename with progressive number. Example:
DSC_0012.JPG
DSC_0582.JPG... (7 Replies)
Discussion started by: vegetablu
7 Replies
LEARN ABOUT LINUX
dbs-edit-patch
DBS-EDIT-PATCH(1) Debian Build System DBS-EDIT-PATCH(1)
NAME
dbs-edit-patch - Edit a DBS patch
SYNOPSIS
dbs-edit-patch [options] patch
dbs-edit-patch -h|--help
DESCRIPTION
dbs-edit-patch is script to generate or modify patches for Debian source-packages in DBS format.
WARNING
dbs is deprecated, please switch to the `3.0 (quilt)' Debian source package format instead. See http://wiki.debian.org/Projects/Deb-
Src3.0#FAQ for a short guide how to do it.
OPTIONS
-h, --help
Show summary of options.
-t dir, --tmpdir=dir
Directory for the temporary files, default is /tmp or if set $TMP.
-s dir, --sourcedir=dir
Top level directory of the debian-package source-tree, default is the present working directory.
-P dir, --sourcepatchdir=dir
Directory containing upstream patches.
-T dir, --sourcetardir=dir
Directory containing the upstream tarball.
-p level, --strip=level
Striplevel -p of patch (Option -p of diff(1)), accepted values are 0 and 1, default is 0.
ENVIRONMENT VARIABLES
TMP Sets the directory for the temporary files, can be overridden with -t dir.
debian/vars
dbs-edit-patch will automatically use variables defined in the optional debian/vars file.
When a file debian/vars.in exists and debian/vars either does not exist or is older than any of the following files: debian/vars.in,
debian/changelog, debian/rules or debian/control, then dbs-edit-patch will try updating the vars file by running the following command
make -f debian/rules -W debian/vars.in debian/vars
EXAMPLES
Edit the 021_debian patch of Heimdal:
~/heimdal-0.3d> dbs-edit-patch -t/tmp 021_debian
Extracting source heimdal-0.3d.tar.gz ... successful.
Applying patch 001_replay ... successful.
etc.
Copying heimdal-0.3d to heimdal-0.3d-old ... successful.
Applying patch 021_debian ... successful.
Edit files under /tmp/021_debian/heimdal-0.3d as required, then put a short description into /tmp/021_debian/patch-description if desired,
and finally execute /tmp/021_debian/dbs-update-patch to save the results.
Technical note: dbs-edit-patch extracts all patches before 021_debian into /tmp/021_debian/heimdal-0.3d, copies the result to
/tmp/021_debian/heimdal-0.3d-old, and applies the last patch 021_debian (if it exists). Also, it creates a shell script which will create
the diff between the old and new directories:
~/heimdal-0.3d> ls -la /tmp/021_debian
total 12
-rwxr-xr-x 1 bam users 112 Jan 31 13:31 dbs-update-patch*
-rw-r--r-- 1 bam users 0 Jan 31 13:31 patch-description
drwxr-xr-x 14 bam users 4096 Jan 31 13:31 heimdal-0.3d/
drwxr-xr-x 14 bam users 4096 Jan 31 13:31 heimdal-0.3d-old/
drwxr-xr-x 5 bam users 4096 Jan 31 13:31 .stampdir/
~/heimdal-0.3d> cat /tmp/021_debian/dbs-update-patch
#!/bin/sh -e
cd "/tmp/021_debian"
HOOK_DIR="/usr/src/heimdal/debian/dbs-hooks"
test -d "$HOOK_DIR" && run-parts "$HOOK_DIR" --arg update-patch-prediff
find -name "*.bak" -print0 | xargs -0 --no-run-if-empty rm
find -name "*~" -print0 | xargs -0 --no-run-if-empty rm
: > new_patch
test ! -e patch-description || cp patch-description new_patch
diff -ruN heimdal-0.3d-old heimdal-0.3d >> new_patch || test $? -eq 1
mv new_patch /usr/src/heimdal/debian/patches/021_debian
test -d "$HOOK_DIR" && run-parts "$HOOK_DIR" --arg update-patch-postdiff
SEE ALSO
diff(1), dbs(7), /usr/share/doc/dbs/
AUTHOR
DBS was written by Adam Heath, modified by Ben Collins, modified and packaged for Debian by Brian May. This manpage was generated by
Andreas Metzler and modified by Robert Luberda.
Debian February 15th, 2011 DBS-EDIT-PATCH(1)