LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-29-2008, 10:39 PM   #1
infonlinebr
LQ Newbie
 
Registered: May 2008
Posts: 20

Rep: Reputation: 0
Rename Folder in numerics


I have one folder with other folders with names bagunšados well and I rename all folders in order number 001/ 002/ 003/...
 
Old 05-30-2008, 03:15 AM   #2
bkcreddy17
Member
 
Registered: Feb 2008
Location: India-Hyderabad
Distribution: RHEL and Fedora
Posts: 171

Rep: Reputation: 15
i could get you. Do you mean, that you have a folder say AAA. It contains some folders like, x,y,z. Now you want to rename them as 001/ , 002/, and so? If this you need to write a script.
 
Old 05-30-2008, 06:56 AM   #3
infonlinebr
LQ Newbie
 
Registered: May 2008
Posts: 20

Original Poster
Rep: Reputation: 0
Yes I have folders with names "archives_001/" or "texts/" and I wanted to rename all as "001/" "002/"...
 
Old 05-30-2008, 07:08 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
You can create new names of directories using printf in a while loop, passing the list of directories using process substitution, e.g.
Code:
#!/bin/bash
while read dir
do
  let $((count++))
  mv "$dir" $(printf "%03d" $count)
done < <(find . -mindepth 1 -type d)
you have to find a criterium to sort directories (if needed) and refine the find command to let it give the correct order.
 
Old 06-09-2008, 01:36 PM   #5
infonlinebr
LQ Newbie
 
Registered: May 2008
Posts: 20

Original Poster
Rep: Reputation: 0
I am making a catch of names to be evidence of a folder, but the images are on the server with different names, and they are more than 200 thousand images and 5000 folders, is to enter into each folder and rename 001.jpg, 002.jpg ?

The most you could rename it was a line of subdirectories.

Last edited by infonlinebr; 06-09-2008 at 01:41 PM.
 
Old 06-10-2008, 12:43 PM   #6
infonlinebr
LQ Newbie
 
Registered: May 2008
Posts: 20

Original Poster
Rep: Reputation: 0
I found a code

Code:
find . -type f | while read I; do NEWNAME1=$( md5sum "$I" | cut -d " " -f 1 ); NEWNAME2=$(dirname "$I")/$NEWNAME1^$( basename "$I"); mv "$I" "$NEWNAME2"; done;
mas ele renomear para o md5 das imagens, e quando tentei adaptar ele apagou uma centena de imagens.
 
Old 06-10-2008, 01:35 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Can you please translate that into English?
 
Old 06-10-2008, 02:02 PM   #8
infonlinebr
LQ Newbie
 
Registered: May 2008
Posts: 20

Original Poster
Rep: Reputation: 0
sorry...
but to rename it the md5 of the images, and when I tried to adapt it deleted a hundred images.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
rename last character in file/folder name BoraX Programming 9 10-26-2006 10:01 AM
Folder Max Size and Limiting SSH access to home folder. Mefistofeles Linux - General 4 11-26-2005 02:09 PM
rename file with "mv" not working for folder? Niceman2005 Linux - Newbie 2 03-13-2005 09:34 PM
how can i default the max folder file size when it create inside a folder antony_csf Linux - Software 1 06-17-2004 02:26 AM
rename file/folder command hct224 Linux - Newbie 4 09-19-2003 09:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration