replacing all the files in a directory with links or blanks

Using applications, configuring, problems
Post Reply
Message
Author
saladinsmith
Posts: 5
Joined: Sat 30 Nov 2013, 03:32

replacing all the files in a directory with links or blanks

#1 Post by saladinsmith »

I have a directory with 1858 .wav files. They take up too much space, and I don't want them, but they're used by a program that I want to keep on my Puppy CD. The program can either run them from from the package they originally came from (70 MB) or the directory I've extracted them all to (74 MB).

I've thought up two solutions:
1. Make an empty file in Geany and save it as blank.wav, then replace all 1858 files with copies of blank.wav, named like they're the original files, and repackage them. (Alternately, use an actual audio program to make a blank.wav.)
2. Make a blank.wav by whichever method in the previous solution, and create 1858 links to it with the names of the original files.

Which solution is better, and how do I do it? (Other than doing it by hand, of course.)

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#2 Post by sunburnt »

I`m sure others are wondering also, why do you want to remove them from a CD.?
And what makes you think the app will work without them.? Most apps would fail.

In answer:

Code: Select all

cp -sP /path/to/files /path/to/dir
This will make links in your new dir that point to the original files.
I`m not sure what this is going to accomplish for you.

To makes links named for original files that all point to one file:

Code: Select all

ls /path/to/org/files/* |while read F ;do ln -s /newPath/oneFile /newPath/$F ;done
Try it and see what you get. I`m guessing none of it will work how you think.

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#3 Post by MochiMoppel »

Maybe this works for you. The script reduces files to zero length. I use it to "nullify" mp3 files I don't like which are part of an album (=directory), but which I want to keep as placeholders so the track list (=file list) doesn't change. As my files are sorted by filedate I normally want to keep filedates, so this is possible as an option.

Note that the original files are not "replaced" by blank files but rather reduced to blanks, so any links pointing to these files will not brake.

1. Save the script and make it executable
2. Open ROX and select all files you want to turn into blank files
3. Enter Shift+!, which brings up the shell box at the bottom of the ROX window with the entry "$@"
4. Add the name of your script. The shell box should now read myscript "$@"
5. Press ENTER

Alternatively you can drag the script from ROX to the desktop (to create a shortcut) and then drag your selected files onto the shortcut.

Code: Select all

#!/bin/sh 
 if [ ! "$@" ];then 
 gxmessage "\ 
    Script sets file sizes to 0 
    Requires at least 1 filespec as parameter" 
    exit 
 fi 

 ANSWER=`Xdialog   --stdout --check "Keep filedate" "on" --default-no --title "Create Nullfiles, keep dates"  --icon "/usr/local/lib/X11/pixmaps/question.xpm" --yesno "Set $# files to zero length?\n\n\n\n" 300x120` 
 [ $?  != 0 ] && exit 

 for FILE in "$@" ;do 
    OLDDATE=`stat -c %Y $FILE`                             # get unix date of current file 
    OLDDATE=`date -d @$OLDDATE +"%Y%m%d%H%M.%S"`           # convert to format compatible with 'touch' command 
    /dev/null > "$FILE"                                    # reduce filesize to zero (also sets new filedate) 
    [ $ANSWER = "checked" ] && touch -cht $OLDDATE "$FILE" # apply old filedate 
    [ $ANSWER = "unchecked" ] && touch -c "$FILE"          # Not really necessary, but causes ROX to refresh display 
 done

saladinsmith
Posts: 5
Joined: Sat 30 Nov 2013, 03:32

#4 Post by saladinsmith »

Thanks. I'll give it a try. I'm pretty sure this will work because you can replace the wavs without crashing it.

(Did I post this in the wrong place? I seem to remember someone saying that, but I'm not seeing it now.)

Post Reply