LoneReaper Posted June 6, 2006 Share Posted June 6, 2006 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 More sharing options...
Paulie Posted June 6, 2006 Share Posted June 6, 2006 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 .jpgAny Ideas?Its simple I know.Look into "filemove" in the helpfile Link to comment Share on other sites More sharing options...
CyberSlug Posted June 6, 2006 Share Posted June 6, 2006 ; one way $newName = StringReplace($oldName, ".jpg", "_1_small.jpg") FileMove($oldName, $newName) Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
LoneReaper Posted June 6, 2006 Author Share Posted June 6, 2006 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 successfulIf $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") ExitEndIfWhile 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 More sharing options...
LoneReaper Posted June 6, 2006 Author Share Posted June 6, 2006 oops. I found my mistake. Its where I had the images located. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now