0

I copied all my files from Ubuntu to a new Windows 10 computer. Many of these files (literally thousands of them) are plain text files without extensions ...

Every time I try to open one of these files in Windows it doesn't know which app to use, so it asks me. Then I have to first click the "EditPad Lite" icon (my default app for plain text files), then I have to click the "OK" button. Only then will Windows finally open the file. As you can imagine, this is a major PITA when my plan is to open and review all these files manually.

Please note that when I perform the above procedure Windows does NOT give me a checkbox option to "Always use this app to open files of this type", so apparently Windows does not know what type of file it is without an extension. I did not anticipate this issue when moving from Ubuntu to Windows because apparently Ubuntu knows what kind of files they are without extensions.

Ideally I could configure Windows to always use EditPad Lite (or some other Windows-based text editor) to automatically open files without extensions, but this seems impossible -- or at least I have failed to find any online information that explains how to do this. So if this is actually possible, can you please tell me how to do it?

Alternately my second-best option (or maybe this is the better option anyways?) is to have Windows batch-rename all my no-extension Ubuntu files by appending .txt to their names:

All the files I copied from Ubuntu to my Windows computer are located in my Home folder or in a nested subfolder of my Home folder. There could be a dozen or more nested subfolder levels in my Home folder, so any script I might use to rename my no-extension files would need to find and rename these files in all my nested subfolders.

Can you possibly post a script that I can use to perform this batch-renaming task?

2

5 Answers 5

1

I knew that somehow it would be possible to RECURSIVELY accomplish this task, but no one posted an answer in this thread, so Google eventually helped me find success in another forum.

Here's what worked for me via the command line (not via a batch file). The first command enters the correct main directory, and the second command recursively appends .txt to all no-extension files in that directory and all its sub-directories:

cd \Users\Fred\Documents\test

for /r %x in (*.) do ren "%x" *.txt
1
@echo off

cd /d "d:\full\path\folder"

for /f delims^= %%i in (`where /r . *.')do ren "%%~i" "%%~ni.txt"
0

rename *. *.txt - make sure there is a space between the first . and *

This will add .txt to all files without an extension - non recursive so do this individually in each folder

2
  • Thank you JohnnyVegas. I tried it and it works for the files in a single folder. Does anyone know how I might run this script recursively so that it "does the right thing" in all nested subfolders? Commented Jul 5, 2022 at 12:04
  • superuser.com/questions/205083/… please mark my answer as correct too - thx Commented Jul 5, 2022 at 16:57
0

Use a single percent sign % to carry out the for command at the command prompt. Use double percent signs %% to carry out the for command within a batch file. So this works for me:
for /r %%x in (*.) do ren "%%x" *.txt

0

I have files like

log.txt.01
log.txt.02
log.txt.03

And, I need to rename them as:

log01.txt
log02.txt
log03.txt

I tried the below batch file script and it worked.

@echo off
Setlocal enabledelayedexpansion

Set "Pattern=.txt."
Set "Replace="

For %%a in (*.*) Do (
    Set "File=%%~a"
    Ren "%%a" "!File:%Pattern%=%Replace%!"
)
for /r %%x in (*.) do ren "%%x" *.txt
0

You must log in to answer this question.

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