Jump to content



Photo

Change File Name


  • Please log in to reply
4 replies to this topic

#1 Omga4000

Omga4000

    Wayfarer

  • Active Members
  • Pip
  • 54 posts

Posted 06 September 2011 - 12:32 PM

Hey all :mellow:

So I was trying to change a file name using FileMove, but it didn't work for me.
(Maybe I just didn't use it in the right way?)

Is there another way to change a file name?

Thank you! :)





#2 water

water

    ?

  • MVPs
  • 10,679 posts

Posted 06 September 2011 - 12:35 PM

How do you call FileMove and what is the return value?

UDFs:

Active Directory (2012-10-12 - Version 1.3.0.0 released) - Download - General Help & Support - Example Scripts - Wiki

OutlookEX (2012-10-07 - Version 0.9.0.0 released) - Download - General Help & Support - Example Scripts - Wiki

ExcelChart (2013-01-21 - Version 0.3.1.1 released) - Download - General Help & Support - Example Scripts

WordEX (2012-12-29 - Version 1.3 released) - Download

ExcelEX (2013-05-11 - Alpha 4 released) - Download


#3 Omga4000

Omga4000

    Wayfarer

  • Active Members
  • Pip
  • 54 posts

Posted 06 September 2011 - 12:37 PM

I've simply copied the line from the help file:
http://www.autoitscript.com/autoit3/docs/functions/FileMove.htm

FileMove("C:\foo.au3", "D:\mydir\bak.au3")


and all I did was just change the destination.
Sometimes it worked, sometimes it didn't.. Weird.

EDIT: It does work right now. Even weirder :mellow:
However now I have another problem.
How do I use a variable in this code?

I need to change the files names and add a number to the beginning.
e.g:
a.txt --> 3a.txt
b.txt --> 3b.txt

I've tried something like this:
$num = 11 FileMove("C:\text.txt", "c:\" & $num & "text.txt")

But it didn't work of course..

Edited by Omga4000, 06 September 2011 - 12:50 PM.


#4 water

water

    ?

  • MVPs
  • 10,679 posts

Posted 06 September 2011 - 12:57 PM

Change your code to do some error checking

$num = 11 $iResult = FileMove("C:\text.txt", "c:\" & $num & "text.txt") MsgBox(0,"", "Result: " & $iResult)

Edited by water, 06 September 2011 - 12:58 PM.

UDFs:

Active Directory (2012-10-12 - Version 1.3.0.0 released) - Download - General Help & Support - Example Scripts - Wiki

OutlookEX (2012-10-07 - Version 0.9.0.0 released) - Download - General Help & Support - Example Scripts - Wiki

ExcelChart (2013-01-21 - Version 0.3.1.1 released) - Download - General Help & Support - Example Scripts

WordEX (2012-12-29 - Version 1.3 released) - Download

ExcelEX (2013-05-11 - Alpha 4 released) - Download


#5 Omga4000

Omga4000

    Wayfarer

  • Active Members
  • Pip
  • 54 posts

Posted 06 September 2011 - 01:03 PM

Now I get it.. Thank you! :mellow:




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users