Jump to content
Sign in to follow this  
qwertylol

renaming files

Recommended Posts

qwertylol

how do i write a script to rename every file in a folder to 1.txt ~ 999.txt?

Share this post


Link to post
Share on other sites
Generator

Try to use _FileListArray(). There are few topics in the example forum.

Edited by Generator

Share this post


Link to post
Share on other sites
Valuater

Because AutoIt lacks a "FileRename" function, use FileMove to rename a file!

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
qwertylol

Because AutoIt lacks a "FileRename" function, use FileMove to rename a file!

8)

uh i am very out of it, i get it to use *.txt in the "source", but i am not sure about dest

Share this post


Link to post
Share on other sites
qwertylol

uh i am very out of it, i get it to use *.txt in the "source", but i am not sure about dest

Do

Filemove ( "source", "dest" )

Filemove ( "*.txt", "$counter + txt" )

Until done

how do i write the "dest" part?

Share this post


Link to post
Share on other sites
Generator

Put them in @TempDir

Share this post


Link to post
Share on other sites
qwertylol

Dim $counter = 0

Do

Filemove ( "*.txt", $counter & '.txt')

$counter = $counter + 1

Until $counter = 344

Share this post


Link to post
Share on other sites
SmOke_N

Dim $counter = 0

Do

Filemove ( "*.txt", $counter & '.txt')

$counter = $counter + 1

Until $counter = 344

You could run into some serious issues with what you have there, better think through your logic a tad.
#include <file.au3>
$aArray = _FileListToArray(@ScriptDir, '*.txt')
For $iCC = 1 To UBound($aArray) - 1
    FileMove(@ScriptDir & '\' & $aArray[$iCC], @ScriptDir & '\' & $iCC & '.txt')
Next

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.