1

Some months ago I have downloaded a dataset in UCI Machine Learning site composed as being one file with various subfolders inside, and each one of these subfolders with more subfolders inside, these subfolders are in gzip format and until so I have unzipped them with Winzip.

These last subfolders each one of them contained a single file in File xxx format (ex: File 001, File 002, File 003 and so on being their extension as .001, .002...) they can be opened in MS Excel or any spreadsheet or notepad file, until so it's okay but I would like to set a default program to open each one of these files (File 001, File 002, File 003...) without that I need to stay clicking right button one by one and choosing a program to open each one of them what is a boring task.

I would like to know how could I convert them (File 000 (.000), File 001 (.001)...) to txt file? I have tried to select all of them and press right mouse button and properties but I can't able to see any open with option and I didn't want to merge all of them yet. My OS is Windows 7 Home Premium

2 Answers 2

2

Open the command prompt and navigate to the directory (use cd "directory name" to move forward, cd.. to move backward)

If all the files are in the one folder type:

ren *.* *.txt

if you need to work recursively through multiple directories from the root folder type:

for /R %x in (*.*) do ren "%x" *.txt

from Recursively rename files through the command line (Windows 7)

If you have other file types in the directories you do not want to change then you could try changing the . to .0 or .00 depending on how many files you are looking at.

1

For rename your files:

Use a for loop command to list your files with numbers in the extension recursively, and, where found, rename them.

1) Use the command Where.exe with /r (recursively) in the root directory tree (.) of your files and filtering only files with exactly 3 characters (???) in the extension...

where.exe /r . *.???

2) Run the where.exe command redirecting the output to findstr, where you are using a regex (\.[0-9]*), so that you can get exactly the files in which the last 4 characters with numbers match precisely that range of .000 to .999.

  • Obs.: Regex: "\" + "." == "\." == literal "."
^|%__APPDIR__%findstr.exe /re \.[0-9]*

3) The loop variable returns the files resulting from the filters previously applied and with their full path accessible in %~i, leaving only the action to rename them, keeping the current name (%~ni) and adding the desired extension (.txt).

')do rename "%%~i" "%%~ni.txt"
  • Your command to rename only the files that contain numbers in the extension, which can occur from 0 to 999 with leading zeros recursively, looks like this:
for /f tokens^=* %i in ('%__APPDIR__%where.exe /r . *.??? ^|%__APPDIR__%findstr.exe /re \.[0-9]*')do @echo/ren "%~i" "%~ni.txt"
  • Your bat/cmd file to rename only the files that contain numbers in the extension, which can occur from 0 to 999 with leading zeros recursively, looks like this:
@echo off 

cd /d "D:\folder\target\"

for /f tokens^=* %%i in ('
%__APPDIR__%where.exe /r . *.??? ^|%__APPDIR__%findstr.exe /re \.[0-9]*
')do rename "%%~i" "%%~ni.txt"


With regard to associating file with .numbers in your extension to MS Excel...

The action of assigning association to MS Excel to open files with numeric extension, I believe, is not recommended, if you really want to do that, I suggest that before make this a new question, where you would get an accurate and secure answer, supported by one of the experienced and trained users of this community. ...

  • I certainly do not recommend doing this action ... Anyway, excuse me, I prefer not to recommend it, because the compressors / unzips them to handle compressed files in several volumes, and this action can result in something that is not good at some point.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .