Help removing the prefix of more than 10,000 files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help removing the prefix of more than 10,000 files
# 1  
Old 04-02-2008
Help removing the prefix of more than 10,000 files

I have more than 10,000 files that all start with "raw_ddd_04_*". How can I remove the prefix on these files in a single command?
# 2  
Old 04-02-2008
Code:
for file in raw_ddd*
do
     mv "$file" "$(echo "$file" | awk '{sub(/raw_ddd_04_\*/,"")}1')"
done

# 3  
Old 04-02-2008
Hey man, thanks for the command. It'll come in handy.

I should've mentioned this is a windows machine and I was looking for a perl script to do this. Unless I can run this through a UNIX machine and ftp or telnet into the windows box?
# 4  
Old 04-02-2008
Hi,

That's an option, ftp the files to a Unix box, rename them, and ftp them back to the Windows machine...

Or somebody else in the forum might have an equal code for windows.
# 5  
Old 04-02-2008
I was trying to prevent doing that. It's over 16GB in size. Guess I'll do it in groups.

Thanks all!
# 6  
Old 04-02-2008
Quote:
Originally Posted by rubin
Code:
for file in raw_ddd*
do
     mv "$file" "$(echo "$file" | awk '{sub(/raw_ddd_04_\*/,"")}1')"
done

Something is not right with this command. It's trying to rename the file but using the same name. I'm getting errors that the 2 files are the same.
# 7  
Old 04-02-2008
Download and install Microsoft SFU (unix for windows), its free.
Then you won't have to copy all the files.
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract Uniq prefix from a start and end prefix

Dear All, assume i have a file with content: <Start>6000</Start> <Stop>7599</Stop> the output is: 6000 7000 7100 7200 7300 7400 7599 how should we use any awk, sed, perl can do this task, means to extract the uniq prefixes from the start and stop prefix. Thanks Jimmy (3 Replies)
Discussion started by: jimmy_y
3 Replies

2. Shell Programming and Scripting

Removing only Prefix string (!)

Hello everyone, I want to remove only prefix ME_ from all the values that are present in the FILEA. Below code I'm using for this. sed 's/ME\_//g' FILEA > FILEB Using the above code, all ME_ values are getting removed from the file. But the problem here is I want to remove only Prefix ME_... (4 Replies)
Discussion started by: ed_9
4 Replies

3. UNIX for Dummies Questions & Answers

Add foldername as prefix to files

Hi there, I am looping through folders in order to rename the files in the current folder. So, given me being a newbie here, I would do that with a for-loop. The renaming per se should be like this: I want to add the folder-name as a prefix to the files in the folder in question. For instance,... (6 Replies)
Discussion started by: jahndavik
6 Replies

4. UNIX for Dummies Questions & Answers

Take 100MB worth files from 200,000 Files

Hi, I have a process which creates almost 200K files. Each file ranging from 1kb to 5kb. This is almost 2GB of data in all files. I have a requirement where the business needs only 100MB worth of files. Is there a way to get files around 100MB (doesn't have to be exactly 100MB) from all the... (2 Replies)
Discussion started by: grep_me
2 Replies

5. UNIX for Dummies Questions & Answers

Removing prefix from multiple files and renaming file extension

Hello i have the files in this format pdb1i0t.ent pdb1lv7.ent pdb1pp6.ent pdb1tj2.ent pdb1xg2.ent pdb2b4b.ent pdb2ewe.ent Now i have to remove the prefix pdb from all the files and also i need to change the extension of .ent to .txt The new file should look like this ... (3 Replies)
Discussion started by: empyrean
3 Replies

6. News, Links, Events and Announcements

Microsoft "Donates" $3,000,000,000 to Feds

Surreal quote from the news link below: http://www.washingtonpost.com/wp-dyn/articles/A44615-2002Nov12.html (0 Replies)
Discussion started by: Neo
0 Replies
Login or Register to Ask a Question