malfroid
malfroid

Reputation: 159

Rename files without extension with AutoHotkey

I am trying to add .pdf to the filename of files without extension in a folder.

It is possible to rename for example txt files to pdf using the following command:

FileMove, %SourceFolder%\*.txt, %SourceFolder%\*.pdf

Also, I can add .pdf to all files by:

FileMove, %SourceFolder%\*, %SourceFolder%\*.pdf

But I only want to target only the files without extension. How to do this?

Upvotes: 1

Views: 2381

Answers (2)

Joe DF
Joe DF

Reputation: 5548

Example

As suggested by kasper and MCL

SetWorkingDir %A_ScriptDir%

Loop, files\*
{
    if !StrLen(A_LoopFileExt) ; if no file extension
    {
        FileMove,%A_LoopFileFullPath%,%A_LoopFileFullPath%.pdf ;rename file
    }
}

see [Loop, FilePattern]
see [FileMove]

Upvotes: 4

Jatin Bansal
Jatin Bansal

Reputation: 873

@kasper, You can use windows command prompt to rename the file as well as change the extension. Just navigate to the file directory and use command

ren abc.txt abc.pdf

Here abc.txt is old file and abc.pdf is pdf of abc.txt.

Upvotes: 0

Related Questions