You are not logged in.

#1 2010-04-08 16:25:51

Anikom15
Banned
From: United States
Registered: 2009-04-30
Posts: 836
Website

They should add this to coreutils. [prefix]

#!/bin/bash

addtofile="$1"
for file in *
do
    if [ ! -e !"$addtofile$file" ]
    then
        mv "$file" "$addtofile$file";
    fi
done

prefix adds a prefix to all the files in a directory. Use it as so:

$ prefix "prepended string"

Now I'm sure with tweaking you can get it to prefix only a single file, only certain files, etc, but I wrote this mainly for adding prefixes to large numbers of files.


Personally, I'd rather be back in Hobbiton.

Offline

#2 2010-04-08 16:35:34

Pierre
Developer
From: Bonn
Registered: 2004-07-05
Posts: 1,964
Website

Re: They should add this to coreutils. [prefix]

Or just use zsh and "zmv -W '*' 'prefix*'" (didn't test it but something similar should work)

Offline

#3 2010-04-08 16:39:32

alterecco
Member
Registered: 2009-07-13
Posts: 152

Re: They should add this to coreutils. [prefix]

I use rename for stuff like that. Also, have a look at moreutils

Offline

#4 2010-04-08 17:39:39

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: They should add this to coreutils. [prefix]

Thanks for the contribution.

Howver, you should use a more suitable thread title, or post in a more suitable place. If you are serious about having this included in coreutils, there's no point posting it here - send it to the coreutils devs for their consideration.

Offline

Board footer

Powered by FluxBB