i have a little over 100 files named page1.jpg through page106.jpg. How can I rename them all to remove the page word and add 00 in front of the remaining numbers? I realize this might be multiple commands but cp page*.jpg *.jpg didn't work like I thought it would.
Last edited by rbatte1; 07-29-2014 at 09:41 AM..
Reason: Added ICODE tags
You will have to work out the process for doing one, then call do that in a loop for all. I have a few to questions pose in response first:-
Is this homework/assignment? There are specific forums for these.
What have you tried so far, other than a your cp?
What output/errors do you get?
What OS and version are you using?
What are your preferred tools? (C, shell, perl, awk, etc.)
What logical process have you considered? (to help steer us to follow what you are trying to achieve)
Most importantly, What have you tried so far?
The suggestion from chacko193 may or may not work depending on your OS & shell, hence the questions above.
There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.
By way of explanation, cp page*.jpg*.jpg will be expanded to actually be:-
The process will copy all files that match either page*.jpg or *.jpg over the last file alphabetically that matches *.jpg so if you have page999.jpg, that will have been overwritten, unless your OS (unspecified) refuses to multiple copy unless the last item in the list is a directory.
We're all here to learn and getting the relevant information will help us all.
Thank you all for your replies. I did do some initial searching but didn't find one that pertained to my situation... then again i wasn't searching this site specifically, but was using Google instead. Thank you for not flaming me too much!
I'll see what I can come up with for a single file and then use your loop example.. will post when I have it worked out.
---------- Post updated at 05:53 PM ---------- Previous update was at 09:13 AM ----------
Quote:
Originally Posted by rbatte1
Welcome zimmerru,
You will have to work out the process for doing one, then call do that in a loop for all. I have a few to questions pose in response first:-
Is this homework/assignment? There are specific forums for these.
What have you tried so far, other than a your cp?
What output/errors do you get?
What OS and version are you using?
What are your preferred tools? (C, shell, perl, awk, etc.)
What logical process have you considered? (to help steer us to follow what you are trying to achieve)
Most importantly, What have you tried so far?
The suggestion from chacko193 may or may not work depending on your OS & shell, hence the questions above.
There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.
By way of explanation, cp page*.jpg*.jpg will be expanded to actually be:-
The process will copy all files that match either page*.jpg or *.jpg over the last file alphabetically that matches *.jpg so if you have page999.jpg, that will have been overwritten, unless your OS (unspecified) refuses to multiple copy unless the last item in the list is a directory.
We're all here to learn and getting the relevant information will help us all.
Is this homework/assignment? There are specific forums for these. - No, just me trying to do something I have not had to do before.
What have you tried so far, other than a your cp? Tried both cp and mv as these seemed the most logical
What output/errors do you get? - target page9.jpg is not a directory
What OS and version are you using? - Mint Linux 17
What are your preferred tools? (C, shell, perl, awk, etc.) - bash mostly
What logical process have you considered? (to help steer us to follow what you are trying to achieve) logically mv page*. jpg *.jpg seemed like it should strip page from the names but it does not. Since that didn't work I did not make it to the next step of adding the 0's
---------- Post updated at 05:57 PM ---------- Previous update was at 05:55 PM ----------
Quote:
Originally Posted by chacko193
Welcome to the forum.
First of all cp will not rename the file, it will just create a copy of the original file. If you want to rename a file you need to use mv.
If you are using bash, try:
This worked perfectly. Dropped it in a file, saved it, chmod +x and executed it and it worked great!
OS : Oracle Linux 6.8
shell : bash
As shown below, I have multiple files like below (query1-extract_aa, query1-extract_ab, query1-extract_ac, ....)
$ ls -l
total 235680
-rw-rw-r-- 1 reportusr reportusr 30M May 3 11:25 query1-extract_aa
-rw-rw-r-- 1 reportusr reportusr 30M May 3 11:25... (5 Replies)
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)
Hi,
I have hundreds of files with XXX in their file name and I want to rename all of them with YYY in place of XXX.
for ex:
$ ls -1
123XXX789
345XXX678
Output
$ ls -1
123YYY789
345YYY678
I know we can loop in each file and sed to replace and rename each file but ren *XXX* *YYY*... (4 Replies)
Hey guys, I am the definition of a newbie. I am in the process of trying to rip all my dvds onto a new HTPC I setup. While doing this, I am also trying to organize a bunch of other files I already have to proper naming conventions. So far I have just been naming each file separately (I am on a... (4 Replies)
Hi,
In my directory I have many files, for e.g.
file_123
file_124
file_125
file_126
file_127
Instead of renaming these files one by one, I would like to rename them at a same time using same command... they should appear like
123
124
125
126
127
What command(awk or ls or... (3 Replies)
Hi
I need to reanme the multiple file using unix script
I have multiple file
like:
sample_YYYYMMDD.xls
test new_YYYYMMDD.xls
simple_YYYYMMDD.xls
I need to rename this file
sample.xls
testnew.xls
SIMPLE.xls
thanks (8 Replies)
Hi everyone,
I'm very green in Linux.
Please help me to solve my problem.
I have thousands of files and I want to change their names.
They have naming convection: prefix_date_date+1_suffix.nc
prefix: ext-GLORY
date_date+1: 20020101_20020102
and two types of suffix: gridV_R20020130 and... (3 Replies)
Hi all, I have some files like:
pickup.0000043200.t001.t001.data
pickup.0000043200.t001.t002.data
pickup.0000043200.t002.t001.data
pickup.0000043200.t002.t002.data
pickup.0000043200.t003.t001.data
pickup.0000043200.t003.t002.data
I need to rename these files to
... (3 Replies)
How do I remove non-printable characters from all txt files and output the results to one file?
I've tried the following:
tr -cd '\n' < *.txt > out.txt
and it gives ambiguous redirect error.
How can I get it to operate on all txt files in the current directory and append the output to... (1 Reply)
I have several hundred files in one directory which I need to move to another directory with the new extension, for example:
/bb/data/rptmgr* are in the source directory need to be moved to
/bb/data55/rptmgr*.new
Is there an efficient way to do it? Thanks -A (4 Replies)