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?

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jul 04 '22 at 16:17
  • Please see [How to set the default program for opening files without an extension in Windows? - Super User](https://superuser.com/questions/13653/how-to-set-the-default-program-for-opening-files-without-an-extension-in-windows) and [How to Associate a Program with Files that have No Extension](https://www.winhelponline.com/blog/associate-file-no-extension-program/) – w32sh Jul 06 '22 at 17:03

5 Answers5

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
DarkDiamond
  • 1,875
  • 11
  • 12
  • 19
1
@echo off

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

for /f delims^= %%i in (`where /r . *.')do ren "%%~i" "%%~ni.txt"
Io-oI
  • 7,588
  • 3
  • 12
  • 41
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

JohnnyVegas
  • 3,470
  • 1
  • 14
  • 18
  • 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? – Fred Flintstone Jul 05 '22 at 12:04
  • https://superuser.com/questions/205083/which-command-can-i-use-to-recursively-rename-or-move-a-file-in-windows please mark my answer as correct too - thx – JohnnyVegas Jul 05 '22 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

Io-oI
  • 7,588
  • 3
  • 12
  • 41
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
zx485
  • 2,170
  • 11
  • 17
  • 24
Arun AC
  • 109
  • 3