Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
File not created or copied
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Michael Astrosky  
View profile  
 More options Oct 15 2012, 9:04 am
Newsgroups: microsoft.public.scripting.vbscript
From: Michael Astrosky <mastro...@gmail.com>
Date: Mon, 15 Oct 2012 06:04:28 -0700 (PDT)
Local: Mon, Oct 15 2012 9:04 am
Subject: File not created or copied
I ave a long filename with many extranneous characters in it that needs to be lessened and have yesterdays date appended in it. I figured that part out - thanks to Goolge. I need to then move the file from it present location to naother network location - this is the part I fail on repeatedly. I believe it is due to the file not actually being created but just a variable being defined. I have looked at this for so long I am not seeing the error. Can anyone point point my (probably) simply overlook?

I beleive all the parts you need are posted below -

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objMessage = CreateObject("CDO.Message")
Set objShell = WScript.CreateObject("WScript.Shell")
Set objshell = CreateObject("Wscript.shell")

'On Error Resume Next

'Get current date
'-----------------------
strMonth = Month(Date)
If len(strMonth) = 1 Then
        strMonth = "0" & strMonth
End if

strDay = Day(Date)
If Len(strDay) = 1 Then
        strDay = "0" & strDay
End if

strYear = Year(Date)

'strHour = Hour(Time)

'strMinute = Minute(Time)

'strSecond = Second(Time)

strDate = strYear & strMonth & strDay

strPastDay = strDate -1
'-----------------------

'-------------------------------------------------------------------------- --
'Specify variables for Emails
'-------------------------------------------------------------------------- --
strScriptServer = "TECHOPSPC01"
strScriptPath = "\\TECHOPSPC01\C$\Scripts\CSI\Capture\..."
strScriptName = "DFX_Loans_Past_Due file Move to FSCHAUNI01"
'strToEmail = ""
'strCCEmail =
strProcessID = "[LPDR-01]"
strCustomerImpact = "LOW"
strCorporateImpact = "LOW??"
'-------------------------------------------------------------------------- --

'Specify variables for File Paths
'strFromPath1 = "\\techopspc01\C$\CSIeSafeDFX\receive"
'strToPath1 = "\\fschauni01\group_share\special assets retail\special assets\past due report\"
strFromPath1 = "C:\CSIeSafeDFX\receive"
strToPath1 = "c:\treasury\Public funds\"
'Specify variable for File
strFile1 = "DFX_Loans Past Due by PDR*.xls"
strNewFile1 = "DFX_LoansPastDueByPDR"
'#######################'

If Right(strFromPath1, 1) <> "\" Then
        strFromPath1 = strFromPath1 & "\"
End If

        objShell.Run "cmd /c move ""C:\CSIeSafeDFX\receive\DFX_Loans Past Due by PDR*.xls"" C:\CSIeSafeDFX\receive\DFX_LoansPastDueByPDR"
        Wscript.Sleep 4000
        strNewFile2 = "DFX_Loans Past Due By PDR" & strPastDay & ".xls"
        strNewFile2 = strNewFile1 & strPastDay & ".xls"
        objFSO.CopyFile strFromPath1 & strNewFile2, strToPath1, True
'       objFSO.DeleteFile strFromPath1 & NewFile1
        blnEmailNotification = true

Thank you all.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mayayana  
View profile  
 More options Oct 15 2012, 11:02 am
Newsgroups: microsoft.public.scripting.vbscript
From: "Mayayana" <mayay...@invalid.nospam>
Date: Mon, 15 Oct 2012 11:01:59 -0400
Local: Mon, Oct 15 2012 11:01 am
Subject: Re: File not created or copied
  The code you have is rather convoluted. In the docs
for MOVE I don't see anything about using wildcards.
Nor does it say anything about specifying a folder in
the Destination parameter.
   But why are you trying to use DOS (console code)
anyway? You're calling WSHShell to run a DOS command
and then calling FSO to do the same thing! DOS is for
console windows.

  When I try your code I get that the source and
destination are:

C:\CSIeSafeDFX\receive\DFX_LoansPastDueByPDR.xls
c:\treasury\Public funds\

   That looks fine. If it's failing you should be getting
an error, like "file not found". Your post implies that
you're not seeing an error code. If I were you I'd clean
it up, get the CMD code out of there, and use
FSO.FileExists where necessary so that you can check
where the operation fails.

  --
--

"Michael Astrosky" <mastro...@gmail.com> wrote in message

news:e12ceae3-bcb4-4589-a6b4-8125f87041c9@googlegroups.com...
I ave a long filename with many extranneous characters in it that needs to
be lessened and have yesterdays date appended in it. I figured that part
out - thanks to Goolge. I need to then move the file from it present
location to naother network location - this is the part I fail on
repeatedly. I believe it is due to the file not actually being created but
just a variable being defined. I have looked at this for so long I am not
seeing the error. Can anyone point point my (probably) simply overlook?

I beleive all the parts you need are posted below -

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objMessage = CreateObject("CDO.Message")
Set objShell = WScript.CreateObject("WScript.Shell")
Set objshell = CreateObject("Wscript.shell")

'On Error Resume Next

'Get current date
'-----------------------
strMonth = Month(Date)
If len(strMonth) = 1 Then
strMonth = "0" & strMonth
End if

strDay = Day(Date)
If Len(strDay) = 1 Then
strDay = "0" & strDay
End if

strYear = Year(Date)

'strHour = Hour(Time)

'strMinute = Minute(Time)

'strSecond = Second(Time)

strDate = strYear & strMonth & strDay

strPastDay = strDate -1
'-----------------------

'-------------------------------------------------------------------------- --
'Specify variables for Emails
'-------------------------------------------------------------------------- --
strScriptServer = "TECHOPSPC01"
strScriptPath = "\\TECHOPSPC01\C$\Scripts\CSI\Capture\..."
strScriptName = "DFX_Loans_Past_Due file Move to FSCHAUNI01"
'strToEmail = ""
'strCCEmail =
strProcessID = "[LPDR-01]"
strCustomerImpact = "LOW"
strCorporateImpact = "LOW??"
'-------------------------------------------------------------------------- --

'Specify variables for File Paths
'strFromPath1 = "\\techopspc01\C$\CSIeSafeDFX\receive"
'strToPath1 = "\\fschauni01\group_share\special assets retail\special
assets\past due report\"
strFromPath1 = "C:\CSIeSafeDFX\receive"
strToPath1 = "c:\treasury\Public funds\"
'Specify variable for File
strFile1 = "DFX_Loans Past Due by PDR*.xls"
strNewFile1 = "DFX_LoansPastDueByPDR"
'#######################'

If Right(strFromPath1, 1) <> "\" Then
strFromPath1 = strFromPath1 & "\"
End If

objShell.Run "cmd /c move ""C:\CSIeSafeDFX\receive\DFX_Loans Past Due by
PDR*.xls"" C:\CSIeSafeDFX\receive\DFX_LoansPastDueByPDR"
Wscript.Sleep 4000
strNewFile2 = "DFX_Loans Past Due By PDR" & strPastDay & ".xls"
strNewFile2 = strNewFile1 & strPastDay & ".xls"
objFSO.CopyFile strFromPath1 & strNewFile2, strToPath1, True
' objFSO.DeleteFile strFromPath1 & NewFile1
blnEmailNotification = true

Thank you all.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Astrosky  
View profile  
 More options Oct 15 2012, 12:50 pm
Newsgroups: microsoft.public.scripting.vbscript
From: Michael Astrosky <mastro...@gmail.com>
Date: Mon, 15 Oct 2012 09:50:25 -0700 (PDT)
Local: Mon, Oct 15 2012 12:50 pm
Subject: Re: File not created or copied
Thanks for the reply.

The DOS code is there because the orignial file name is DFX_Loans past Due by PDR011833(and then a bunch of miscellaneous characters that always change).xls

what I need to do is change the file name to DFXLoansPastDueByPRD_10152012.xls and then copy that file to another location.

this file comes in everyday and needs yesterday's date appended to it and then moved. I could find no way with VB to rename a file with wildcards.

The code runs, renames the original file to DFX_LoansPastDueBy and then eventually exits. When I debug it I get fil not found when trying to copy to the new location. The variable strNewFile2 does get set to DFX_LoansPastDueBy_10142012.xls but I do not think it is actually created for the move to work.

that is where I am stuck.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mayayana  
View profile  
 More options Oct 15 2012, 3:14 pm
Newsgroups: microsoft.public.scripting.vbscript
From: "Mayayana" <mayay...@invalid.nospam>
Date: Mon, 15 Oct 2012 15:13:46 -0400
Local: Mon, Oct 15 2012 3:13 pm
Subject: Re: File not created or copied

>  I could find no way with VB to rename a file with wildcards.

  Below is "air code" but it should be about right. CopyFile
can actually deal with wildcards but since you just have one
file to deal with I thought it might be easier to just avoid
that complication.

Set oFol = FSO.GetFolder("C:\CSIeSafeDFX\receive")
Set oFils = oFol.Files
  For each oFil in oFils
     sName = oFil.Name
     If Instr(oFil.Name, "DFX_Loans Past Due by PDR") > 0 then
         oFil.Name = "DFX_LoansPastDueBy_10142012" & sDate & ".xls"
         oFil.Copy strToPath1 & oFil.Name, True
         oFil.Delete
         Exit For
     End if
  Next
Set oFils = Nothing
Set oFol = Nothing

 That code uses the File object. Similar operations can be done
doing the copy, delete, etc. via FSO. It doesn't much matter.
But I think either way is more clear than bringing cmd.exe into
it. This way you can use FSO for any debugging needed, you
don't have to see phantom DOS windows, and you can skip
WSHShell.

   You might want to download the WSH help file. It details the
various FSO operations available:

http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Todd Vargo  
View profile  
 More options Oct 16 2012, 2:10 am
Newsgroups: microsoft.public.scripting.vbscript
From: Todd Vargo <tlva...@sbcglobal.netz>
Date: Tue, 16 Oct 2012 02:10:45 -0400
Local: Tues, Oct 16 2012 2:10 am
Subject: Re: File not created or copied
On 10/15/2012 9:04 AM, Michael Astrosky wrote:

Here is a simplification of the relevant parts of your code. You can
merge with whatever other code you deem necessary. This will rename the
file and move it per your code spec. I left out extension verification
because I felt it unnecessary.

Please note, the correct method of working with current date and time to
to first store them in a variable, and then work with the variable
because it will not change while the script is running. This code has
not been tested with UNC paths. You will have to do that on your end.

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objshell = CreateObject("Wscript.shell")

'On Error Resume Next
'Do not use OERN unless error handling code is included

'Get yesterday's date
'-----------------------
d = Date - 1
strMonth = Right("0" & Month(d),2)
strDay = Right("0" & Day(d),2)
strYear = Year(d)

'strHour = Hour(Time)
'strMinute = Minute(Time)
'strSecond = Second(Time)

strPastDay = strYear & strMonth & strDay
'-----------------------

'----------------------------------------------------------------------
'Specify variables for File Paths
strFromPath1 = "C:\CSIeSafeDFX\receive"
strToPath1 = "c:\treasury\Public funds\"

'Specify variable for original Filename prefix and new name
strFile1 = "DFX_Loans Past Due by PDR" ' *.xls
strNewFile1 = "DFX_LoansPastDueByPDR" & strPastDay & ".xls"
'----------------------------------------------------------------------

Set f = objFSO.GetFolder(strFromPath1)
Set fc = f.Files
moved = false
For Each f1 in fc
   s = f1.name
   If Left(Ucase(s),Len(strFile1)) = Ucase(strFile1) Then
     f1.Name = strNewFile1
     objFSO.MoveFile f1.Path, strToPath1
     moved = True
     Exit For
   End If
Next

If moved Then
   MsgBox "File [" & strFile1 & "*.*] renamed and moved to [" & _
     strToPath1 & "\" & strNewFile1 & "].", vbInformation
Else
   MsgBox "File [" & strFile1 & "*.*] not found.", vbExclamation
End If

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dr J R Stockton  
View profile  
 More options Oct 16 2012, 1:27 pm
Newsgroups: microsoft.public.scripting.vbscript
From: Dr J R Stockton <reply1...@merlyn.demon.co.uk.invalid>
Date: Tue, 16 Oct 2012 18:27:40 +0100
Local: Tues, Oct 16 2012 1:27 pm
Subject: Re: File not created or copied
In microsoft.public.scripting.vbscript message <e12ceae3-bcb4-4589-a6b4-
8125f87041c9@googlegroups.com>, Mon, 15 Oct 2012 06:04:28, Michael
Astrosky <mastro...@gmail.com> posted:

That approach should fail if the time in minutes changes during the
execution of that code.  The potency of the failure increases with the
magnitude of the biggest field to change.  You should put   ItIs = Now
at the beginning, and use ItIs as the argument for Year..Second.  You
probably will not notice the effect in test, but it will cause
occasional havoc in production runs.

--
 (c) John Stockton, nr London UK               Reply address via Home Page.
   news:comp.lang.javascript FAQ <http://www.jibbering.com/faq/index.html>.
   <http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
   <http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »