Jump to content

Simple File Renaming


Recommended Posts

I want to rename all files in the directory that I am working in. For some reason I cant get the string functions to work.

I have several files in the working directory that are RV####.jpg and I want to add _1_small after the numbers before the .jpg

Any Ideas?

Its simple I know.

Link to comment
Share on other sites

I want to rename all files in the directory that I am working in. For some reason I cant get the string functions to work.

I have several files in the working directory that are RV####.jpg and I want to add _1_small after the numbers before the .jpg

Any Ideas?

Its simple I know.

Look into "filemove" in the helpfile

Link to comment
Share on other sites

Here is what the script looks like I marked the section I am working on:

#include <FTP.au3>

$filename = StringLeft(@ScriptName,StringLen(@ScriptName)-4)

$ini_file = $filename&".ini"

$file = FileOpen($ini_file, 0)

$server = 'ftp.softwareoutlet.com'

$username = '*****'

$pass = '*****'

FileClose($file)

$images = @ScriptDir&"\images\"

$mini = @ScriptDir&"\images\resized"

$dir = @ScriptDir&"\images\resized\"

$filenames = @ScriptDir&"\images\*.jpg"

$search = FileFindFirstFile($filenames)

$tool = @ScriptDir & "\i_view32.exe"

DirCreate($mini)

Run(@ScriptDir & "\i_view32.exe " & $images & "*.jpg /resample=(145,109) /convert=" & $dir &"*.jpg","", @SW_MINIMIZE)

$firstfile = FileFindFirstFile("*.jpg")

$fixedname = StringLeft("I am a string", 3)

While 1

$file = FileFindNextFile($search)

If @error Then ExitLoop

$filenew = $file

$fixedname = StringReplace ( $filenew, ".jpg" , "")

FileMove($filenew, $dir & $fixedname & "_1_small.jpg")

WEnd

$Open = _FTPOpen('MyFTP Control')

$Conn = _FTPConnect($Open, $server, $username, $pass)

; Check if the search was successful

If $search = -1 Then

MsgBox(0, "Error", "No files/directories matched the search pattern")

Exit

EndIf

While 1

$file = FileFindNextFile($search)

If @error Then ExitLoop

$filenew = $file

$filenew = StringLower(StringReplace($filenew," ", "_"))

$Ftpp = _FtpPutFile($Conn, $dir & $file, '/home/soutlet/websites/www.rvtoyoutlet.com/html/images/screenshots/' & $filenew)

WEnd

$Ftpc = _FTPClose($Open)

FileClose($search)

If I put a msg box in place of the FileMove command, it shows each filename like I want it... Its just not renaming them...

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...