ubuntu-users@lists.ubuntu.com
[Top] [All Lists]

OT: Bash script help needed

Subject: OT: Bash script help needed
From: Craig Puchta
Date: Thu, 20 Dec 2007 08:30:44 -0500
This is off topic, but I'm not sure where to look for answers.

I am looking for some help in making a script to make directories and
move files to those directories. I am doing it manually and since I have
tens of thousands of these files to move, I figure there must be an
easier way to do it.
Here is what I have and want to do.

In one directory I have tens of thousands of .txt files named as such:

rdb-001-001.txt
rdb-001-002.txt
rdg-002-001.txt
rdg-002-002.txt 
and so on.

What I want to do (and not manually, as I haven't even put a dent in it
yet) is:

mkdir rdb-001
mv rdb-001-* rdb-001
mkdir rbg-002
mv rbg-002-* rbg-002

I want to make a script that can grab a file name, make the directory
and move all corresponding files to that directory. The problem is I
don't know what command could grab a file name and make a directory from
it.
Any help would be appreciated. 


-- 
ubuntu-users mailing list
ubuntu-users@xxxxxxxxxxxxxxxx
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-users

<Prev in Thread] Current Thread [Next in Thread>