| View previous topic :: View next topic |
| Author |
Message |
tonne
Joined: 06 Jun 2006 Posts: 1259 Location: Denmark
|
Posted: Thu Jul 17, 2008 10:57 am Post subject: |
|
|
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 |
|
 |
Jow
Joined: 11 Jan 2008 Posts: 34
|
Posted: Thu Jul 17, 2008 11:34 am Post subject: |
|
|
| Hey, whereabouts do I put that in my code? |
|
| Back to top |
|
 |
tonne
Joined: 06 Jun 2006 Posts: 1259 Location: Denmark
|
Posted: Thu Jul 17, 2008 11:40 am Post subject: |
|
|
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 |
|
 |
Jow
Joined: 11 Jan 2008 Posts: 34
|
Posted: Thu Jul 17, 2008 11:59 am Post subject: |
|
|
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 |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6847 Location: Pacific Northwest, US
|
Posted: Thu Jul 17, 2008 3:28 pm Post subject: |
|
|
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 |
|
 |
Jow
Joined: 11 Jan 2008 Posts: 34
|
Posted: Thu Jul 17, 2008 3:48 pm Post subject: |
|
|
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 |
|
 |
Jow
Joined: 11 Jan 2008 Posts: 34
|
Posted: Thu Jul 17, 2008 3:52 pm Post subject: |
|
|
OK - it works now
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 |
|
 |
Jow
Joined: 11 Jan 2008 Posts: 34
|
Posted: Fri Jul 18, 2008 12:06 pm Post subject: |
|
|
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 |
|
 |
|