AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Renaming files in folder
Goto page Previous  1, 2
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
tonne



Joined: 06 Jun 2006
Posts: 1259
Location: Denmark

PostPosted: Thu Jul 17, 2008 10:57 am    Post subject: Reply with quote

Try this:
Code:
...
  StringRight, FileName, A_LoopFileName, 4
  MsgBox Trying to rename %FileName%.pdf to %CellContents%.pdf - did I really find the filename without extension above??
; better read up on StringRight, even consider using SplitPath!!
  FileMove, %FileName%.pdf, %CellContents%.pdf
...

_________________
there's a dog barking close within the range of my ear
sounds like he wants to escape the chain
he would probably bite me to death if he could
but the chain lets me spit in his face

- Kashmir
Back to top
View user's profile Send private message
Jow



Joined: 11 Jan 2008
Posts: 34

PostPosted: Thu Jul 17, 2008 11:34 am    Post subject: Reply with quote

Hey, whereabouts do I put that in my code?
Back to top
View user's profile Send private message
tonne



Joined: 06 Jun 2006
Posts: 1259
Location: Denmark

PostPosted: Thu Jul 17, 2008 11:40 am    Post subject: Reply with quote

Take a look at your code and you will (easily) see that I merely added a debugging messagebox and a comment at the end (bar 2 lines) of your script.
_________________
there's a dog barking close within the range of my ear
sounds like he wants to escape the chain
he would probably bite me to death if he could
but the chain lets me spit in his face

- Kashmir
Back to top
View user's profile Send private message
Jow



Joined: 11 Jan 2008
Posts: 34

PostPosted: Thu Jul 17, 2008 11:59 am    Post subject: Reply with quote

The message box you added says -
"Trying to rename .csv.pdf to 3788145.pdf"

So I guess that shows there's something up...?
Back to top
View user's profile Send private message
engunneer



Joined: 30 Aug 2005
Posts: 6847
Location: Pacific Northwest, US

PostPosted: Thu Jul 17, 2008 3:28 pm    Post subject: Reply with quote

looks like you should change StringRight to StringTrimRight
_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
Jow



Joined: 11 Jan 2008
Posts: 34

PostPosted: Thu Jul 17, 2008 3:48 pm    Post subject: Reply with quote

enguneer, using that made the message box display the correct filenames! -

"Trying to rename file1.pdf to 3788145.pdf"

But it doesn't go on to rename the files?

I can't figure out why...
Back to top
View user's profile Send private message
Jow



Joined: 11 Jan 2008
Posts: 34

PostPosted: Thu Jul 17, 2008 3:52 pm    Post subject: Reply with quote

OK - it works now Smile

I changed the filemove directory to

Code:
  FileMove, %dir%\%FileName%.pdf, %dir%\%CellContents%.pdf


Thanks everyone that has taken the time to help me, really appreciate it.
Back to top
View user's profile Send private message
Jow



Joined: 11 Jan 2008
Posts: 34

PostPosted: Fri Jul 18, 2008 12:06 pm    Post subject: Reply with quote

Is it possible to specify that I want to use only the number in cell A1? I'm having an occasional issue where there is a number in A1 and A2, in which case it doesn't rename and move. I've had a root around but couldn't find any info on it.


Code:
TryAgain:
FileSelectFolder, dir,\\Server-1\production_share
If (ErrorLevel = 1)
{
Msgbox, 4,PROGRAM TITLE, Folder Not Selected.`nDo you want to quit?
IfMsgBox, Yes
ExitApp
else
Goto TryAgain
}


files=*.csv

ifnotexist, %dir%\Completed
FileCreateDir, %dir%\Completed


Loop, %dir%\%files%
{
  FileReadLine, CSVLine, %A_LoopFileFullPath%, 1
  Loop, Parse, CSVLine, csv
  {
    CellContents:=A_LoopField
    Break ; ...then stop
  }
  StringTrimRight, FileName, A_LoopFileName, 4


  FileMove, %dir%\%FileName%.pdf, %dir%\Completed\%CellContents%.pdf
}
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group