There has got to be an easy way to do this (GD try 2)

kyleb

Veteran
I'm wanting to blank out a directory full of files. I know I can do this one at a time manually by creating a blank file named "blank" in the same directory and from command line entering "copy blank whatever.wav" for each file, but surely there is bound to be an easy way replace all the files in the directory at once?
 
Can I ask a similar weird Q in here :)?


I've got a notepad file of text data/numbers, They're somewhat arranged in rows and columns but with plenty of spaces in between each say, number.

Is there any way to transfer that automatically to a spreadsheet without painstakingly hand copying it over?

I've done a little digging, and there doesn't seem to be. CSV format would work, but it seems I'd have to hand insert all the commas and remove all the spaces between data, which would basically be just as difficult as just copying it over in the first place.
________
GLASS PIPE PICTURES
 
Last edited by a moderator:
re: rangers. regular expressions.

re: kyleb. batch file (generate one with Emacs or something).
 
I just downloaded Emacs. Seems like an interesting program. I haven't a clue on how to get it to generate a batch file to accomplish the task at hand though. Any advice?
 
just downloaded Emacs. Seems like an interesting program. I haven't a clue on how to get it to generate a batch file to accomplish the task at hand though. Any advice?
Emacs is basically a text-editor on steroids. I'm no expert on Windows batch so I don't know what's available but I'd probably try something like this:

1. Create a list of the file names in a text file (eg. dir > replace.bat, does that work?)
2. Open replace.bat in Emacs
3. Do M-x replace-regexp, replace ^ with 'copy blank '

that should transmute each line in the file from filename.wav to 'copy blank filename.wav'. Save the batch file and execute in the usual way (whatever that is).

All this stuff is so much easier in Unix shell :)

Can I ask a similar weird Q in here :)?


I've got a notepad file of text data/numbers, They're somewhat arranged in rows and columns but with plenty of spaces in between each say, number.

Is there any way to transfer that automatically to a spreadsheet without painstakingly hand copying it over?

I've done a little digging, and there doesn't seem to be. CSV format would work, but it seems I'd have to hand insert all the commas and remove all the spaces between data, which would basically be just as difficult as just copying it over in the first place.

I've found Excel to be pretty flexible in importing formatted ASCII data, and the Linux free equivalents too. If you try to Load File... then it should pop up a little wizard which will allow you to give it guidance in how to extract the columns from the file, eg. specifiy that the fields are separated by spaces, and so on.
 
actually you should be able to do this just from the windows cmd shell, as it does have a for command.

have your blankfile somewhere seperate to the directory you are wanting to do.
go to the command line, and change into the directory you want to blank out.
Type:
for %f in (*.*) do copy c:\myblankfile.txt %f


Replace c:\myblankfile.txt with the path to your blank file. This script will ask you to confirm, if you want to just do it then try

for %f in (*.*) do xcopy /y c:\myblankfile.txt %f


Whilst the XP command shell isn't quite as powerful as a unix one, it can do quite a lot.

CC
 
I've found Excel to be pretty flexible in importing formatted ASCII data, and the Linux free equivalents too. If you try to Load File... then it should pop up a little wizard which will allow you to give it guidance in how to extract the columns from the file, eg. specifiy that the fields are separated by spaces, and so on.

You can also paste the text file into the excel then use the "Text to Columns" option to separate it out. This method goes wrong if there are tabs between some of the values and not others so be careful. When I do it I replace all tabs with 4 spaces before pasting it in.
 
Thank you Captain Chickenpants, aside from needing a second percentage sign to signify the variable, what you posted did the trick saving me a lot of manual labor. For future use, is there a way I can modify that work not on the files in the directory where the batch file is located but rather on the files in all the directories under it?
 
I think you can use /r, like

for /r %f in (*.*) do ...

Note: this includes ALL files in current directory.
 
Thank you Captain Chickenpants, aside from needing a second percentage sign to signify the variable, what you posted did the trick saving me a lot of manual labor. For future use, is there a way I can modify that work not on the files in the directory where the batch file is located but rather on the files in all the directories under it?

Ah, that is because you were doing it in a batch file. The single percentage things is if you are just working on a command line. A weird behaviour of batch files.


Mcsven I think this is for people who are concerned about someone reconstructing the data on their hard drive, as simply deleting a file will simply remove it from the file allocation table. To properly remove the data you need to replace it with something else.

CC
 
Thank you pcchen, that "/r" is exactly what I was after.

And yeah Captain Chickenpants, that would be one good reason to what I was asking. I'm not concerned with anyone reconstructing any data though, I'm just replaceing all the custom sounds I download in Counter-Strike with blank sound files so I don't have to listen tol the stupid "prepare to fight", "headshot" and all the other crap that that so many people put on their servers. I've now got myself a blank wav file named "blank" along with batch file in my sounds directory which reads:
Code:
@echo off
for /r %%x in (*.wav) do xcopy /Y "blank" "%%x"
for /r %%x in (*.mp3) do xcopy /Y "blank" "%%x"

So now, anytime I download new sounds in CS I can just run that batch file and blank them all out. Thank you again to all of you who helped.
 
Back
Top