Powershell- FTP Script to copy files only after a certain time

Hey guys,
We are currently running an FTP script that decrypts pgp and copies/moves several files to different archived and production locations. These files come in constantly throughout the day and we need to ensure a certain 8 files get moved to 4 different locations
but NOT before a certain time.
Ex: File1 and File2 are received EARLY along with 50 other files and decrypted at 9pm EST on 9/4. File1 and file2 need to WAIT to be moved until after 12:05am EST on 9/5 or it is slapped with an incorrect $date/time and not processed correctly but
every other file needs to be moved (which is currently all configured).
Right now, both file1 and file2 are being moved as the script runs  (every 10 minutes) so when the files come in early from the vendor- they get the incorrect date/time stamp.
I'm fairly new to powershell so I'm not quite sure how to set this up to only move the file if it is between a certain time- say 12am-1am and no other time.

I was able to resolve this myself by doing the following:
$hourdate = get-time –uformat “%H” 
#Copy-Item as long as time is in the 12:00am or 1am hour 
if(($hourDate -eq "0")-or ($hourdate -eq "1")) 
copy-item objects
Thanks guys

Similar Messages

  • Logon Scripts for copying files in Windows 7

    Issues using Logon scripts to copy files in windows 7.  Its default is to append the file rather than copy and replace, which is what XP did.  How can I achieve the same results using
    logon scripts in W7 to copy any files to specified folders and replacing old files.  The reason for this is that we use a software that performs offsite/onsite updates and the only way all the users can have the correct version/tables is to either manually
    update each user in a 90+ user environment or use a logon script to perform the coping of the updates.  Unfortunately the software support won’t create a (while logging in to software) patch for this.  So we have to force it during the user logon.

    Hi Novice,
    It should depend on your script content. it's recommended you ask in the official scripting guys forum for professional help:
    https://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?forum=ITCG
    Karen Hu
    TechNet Community Support

  • Windows Scripting to copy files

    Hi there,
    New to Windows scripting. 
    I have tried to create a simple script to copy file but failed. Most probably the syntax is wrong. Pls help. thanks.
    I give you my code below:
    @ECHO OFF
    SETLOCAL
    REM SET INDIR="\\sge-fs01\enablers_development\ptc\OUTGOING"
    SET SLIFTCMD="C:\Program Files\PrivyLink\SLIFT-Ez Classic\1.4\SLIFTC.exe"
    SET PFX="C:\PrivyLink\KeyPeer\111111.pfx"
    SET PFXPWD="pass12345"
    SET CER="C:\PrivyLink\KeyPeer\sgesftpuser.cer"
    SET PATTERN="*.IN"
    SET DSTDIR="C:\SFTP\OUTBOUND"
    SET BKDIR="C:\SFTP\BACKUP"
    SET SENDDIR="C:\SFTP\SENDTO"
    SET INDIR="C:\SFTP\PTC\OUTGOING"
    REM ####### MAIN CALL #########
    CALL:MainScript
    GOTO :EOF
    REM ####### Check Files in PTC OUTGOING #########
    :MainScript
    SETLOCAL
    @ECHO OFF
    PUSHD %INDIR%
    IF EXIST "C:\SFTP\PTC\OUTGOING\*.IN"
    COPY "C:\SFTP\PTC\OUTGOING\*.IN" %DSTDIR%
    ELSE 
    echo "There are no files today - %date:~-4,4%%date:~-7,2%%date:~-10,2%" >> C:\SFTP\PTC.log
    pushd %~dp0
    start "" cmd /c cscript SMTP.vbs
    POPD
    ENDLOCAL
    GOTO :EOF
    REM ####  END ########

    I tried myself and it works now. 
    EXISTS can use wildcard (no problem with that). Just that my brackets were not in right position.
    They should be like this:
    IF EXIST "C:\SFTP\PTC\OUTGOING\*.IN" (   
                                    COPY %INDIR%"\*.IN" %DSTDIR%
                                    REM COPY "C:\SFTP\PTC\OUTGOING\*.IN" %DSTDIR%
                                    REM CALL :ENCRYPT
                    ) ELSE (
                                    echo "There are no files today - %date:~-4,4%%date:~-7,2%%date:~-10,2%" >> C:\SFTP\PTC.log
                                    pushd %~dp0
                                    start "" cmd /c cscript SMTP.vbs

  • IPOD freezes after a certain time

    After a certain time using the device, the touch display does not work anymore. The app is still running, but not reacting any more. After switching off the Ipod is working again for a certain time.
    The device has been rebooted several times, restored via Itunes and also the firmware is up to date.
    The device is one year old, 8GByte, enough memory available and the battery charged.
    The problem started some weeks ago.
    I started to remove some apps without success actually.
    Apps that have a bigger size seem to increase the occurence of the problem
    Using WiFi increase the occurence also.
    Any ideas welcome!!!

    Here finally the solution for my problem:
    The hardware of the Ipod had a problem. The device had been replaced by a new one. As I bought the device in Germany, there is an extended warranty of 24 month. The retailer where I bought the device took it back and gave the complete money back including the shipment costs! So I ordered the now IPod Touch G4 and have now fun again.
    The suggestion which already had been given was correct and helpful.
    A comment about the retailer:
    I bought the device via Amazon. There support even on a Sunday evening was just great. In one week (!!!) I sent the device (on Monday), got the result of the investigation and received the new device (on Friday).
    The support I received here was just great!

  • IDVD is closing after a certain time.

    Hi, i made a movie with a sony Z1-HDV camera and made the montage in FCP. Than i export it with Quicktime 7.5. Than dropped it in iDVD. After a certain time iDVD just quits. With the below report.
    Also when i just open iDVD and open an other iDVD project and do nothing iDVD just quits after a certain time. Read below report.
    What to do???? I have to finish this project by wednesday!!!! HELP!!!
    Process: iDVD [512]
    Path: /Applications/iDVD.app/Contents/MacOS/iDVD
    Identifier: com.apple.iDVD
    Version: 7.0.2 (1100)
    Build Info: iDVD-11000000~17
    Code Type: X86 (Native)
    Parent Process: launchd [84]
    Date/Time: 2008-08-03 19:43:10.272 +0300
    OS Version: Mac OS X 10.5.4 (9E17)
    Report Version: 6
    Exception Type: EXCBADACCESS (SIGBUS)
    Exception Codes: KERNPROTECTIONFAILURE at 0x0000000000000000
    Crashed Thread: 22

    Yikes! You're on the very edge of a kernel panic if you haven't yet seen one. Something is amiss ....
    Are you using any external FW or USB HD's / 3rd party devices while attempting to burn an iDvd?
    If so, Restart your Mac without any 3rd party devices attached and try again. But first run apple's disc utilities to Repair Permissions. Assuming you have no less than 20GB's of available HD space on the boot volume and that all assets for iDvd are located on this same volume (your main HD and not on the external volume/s).
    Post back with your results.
    Message was edited by: SDMacuser

  • Do notes disappear after a certain time?

    The earliest entry in the Notes app has disappeared. Do they get deleted after a certain time or if I have inadvertantly deleted it can i get it back from icloud somehow?

    They never expire - at least from iCloud.  I still have some five year old notes.

  • Do notes go away after a certain time?

    Do notes on the iphone4 go away after a certain time?  One of my most important note is gone.

    How old are you? If 1998 is the year you were born, it's entirely possible your parents have subscribed to a 'smart limits' service, which will disable your data connection, text messaging, etc. during hours they choose.

  • Is there a feature in Adobe Acrobat that allows me to create a PDF that has a 'self destruct' capability?  We have a situation where we need to allow people to download PDF files, but after a set time (48 hours), the file can't be opened and read (e.g., s

    Can Acrobat create PDF files that once downloaded - can't be opened after some preset time (48 hours)?

    Hi Edward lkeda,
    I am not very sure of that however as per my knowledge , you can use Adobe send service and provide public link to your users and then after 48 hrs you can delete the file from server and make File-link inaccessible.
    Hope that helps,
    Please revert back for any further query. I will try my best to help you with your problem.
    Regards,
    Rahul Tyagi

  • Using spry:state="loading" only after a certain interval

    Hi everyone ,
        I need a feature for spry regions. I want my loading spry state to show only loading of data takes 0.5 seconds and more.
    Is it possible with this version of spry?
    Ps1 : you can find a live example of my need in google webmaster tools' content section,content by title page. There is an ajax listview with paging on page and loading div only apeears if loading of data takes more than a certain milliseconds.
    Ps2 : Spry rulezzzz

    vw2ureg wrote:
    Hi,
    Go here and scroll down to ErrorState, LoadingState and ReadyState.
    I hope this helps.
    Ben
    That will only tell Spry that it should should use different "state" as loading state. But it doesn't display a loading state after a certain interval. This functionality does not exist in the Spry library. But you could create a custom "loading" state that you automatically trigger using setTimeout if your haven't gotten a onPostUpdate through your region observer.
    But i'm curious why you would wanna do create a have the loading state after a certain interval.

  • Getting labview to stop after a certain time.

    I'm trying to get labview to stop running after a set time? I have a load cell attached to a NI ELVIS board and once the set load is read by labview it's outputting a voltage thourgh the board but continuesly till the load is removed. I would like to ouptut the voltage to stop after a certain amount of time with the load still on the load cell.

    bmira1 wrote:
    I would like to ouptut the voltage to stop after a certain amount of time with the load still on the load cell.
    Of course stopping LabVIEW (as described in the post title) and stopping an output voltage (as described in the post body) are two completely different things! Blindly stopping LabVIEW will not necessarily reset any active analog output to zero.
    Best would be a simple state machine that changes the output to zero after a certain elapsed time. This could for example be done with the timeout case of an event structure or even with the "elapsed time" express VI (or with the code fragments given above after you make sure there is a small wait in the polling loop)
    When the experiment starts, write a certain voltage to the output once (You don't need to do that over and over, only when the voltage changes) and, after the time has elapsed, write a zero voltage to the output.
    No need to stop LabVIEW. You should actually disable or catch "panel close?" events and other abnormal shutdown attempts, and reset the outputs in an orderly fashion before allowing the program to stop.
    LabVIEW Champion . Do more with less code and in less time .

  • Call quality gets choppy after a certain time

    Hello, Having an issue with my Comcast phone service.  Quality seems to be good (for VOIP) on most calls, however, if I have a call that runs over 45 minutes or so, the line gets choppy and I'm only able to hear about 1 out of every 3 words.  This happens consistenty on longer calls after a certain period of time (usually after around 45 minutes).  There doesn't seem to be any problem at all during shorter calls, but it's incredibly annoying since I use my phone for work and many of my work calls run longer. Thanks,Ryan

    Group video calls have a fair usage policy so if you are doing a group video call more than 4 hours a day/100 hours a month then you could have issues.  Normal video calls should not have that limitation though I could imaging there could possibly be a limitation if you attempted to keep a single video call running 24x7x365.
    http://www.skype.com/en/legal/gvc-fair-usage/

  • How can I set a passcode that is only required at certain times of the day. Ie: my child needs access for school use, but don't want her playing iPad in the middle of the night. I cannot identify a way to have the iPad turn off or require a password

    I cannot find a way to enable my child's iPad to require a passcode only at certain times of the day.
    Yes I have used the clock/timer/ countdown - great to restrict how many minutes of iPad usage they get a day.
    But as my child requires the iPad in school for class lessons the usage at school varies maybe 30 mins 1 day and a few hrs on other days
    I want the ability to say set the iPad to not work between say 7pm and 7am, ( unless a passcode is entered) so my child isn't playing games on it in the middle of the night...
    Apple I cannot see anything in the settings that performs this function
    Help

    You can Remote Lock his iPad with Find My iPad using a computer at whatever time you like.
    http://support.apple.com/kb/PH2700
    Note: The iPad may be disabled if he tries the passcode too many times.

  • Script to copy files when connecting camera?

    Being ever increasingly worried about losing data, especially photos/movies of our family etc, I'd like to have some sort of script/automated process so that when I connect my camera (Canon 400D) - my iMac grabs a copy of the original images from the device and transfers(copies) them to an external drive, or if this is not possible, at least to another location.
    Is this possible, and any ideas on the best/easiest way to acheive this?
    Thanks.
    FWIW - I have multiple usb drives connected, some direct into the iMac, one into my Time Capsule, and also access to my RAID NAS drive - which is where I would prefer to store them, as it offers the most secure medium to backup to.

    You can use Automator to create a folder action that would import the image files into iPhoto and then copy them to a destination folder. You would, however, have to have to use Image Capture or a card reader to upload the files from the camera to the folder.
    Actually, Larry's suggestion of keeping a current, i.e. daily, backup of your iPhoto LIbrary on another drive with a backup application like Synk Standard is the very best route to go. AND never let iPhoto delete the photos from the camera. Always reformat the card using the camera.
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto (iPhoto.Library for iPhoto 5 and earlier versions) database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
    I've created an Automator workflow application (requires Tiger or later), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. There are versions that are compatible with iPhoto 5, 6, 7 and 8 libraries and Tiger and Leopard. Just put the application in the Dock and click on it whenever you want to backup the dB file. iPhoto does not have to be closed to run the application, just idle. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.
    NOTE: The new rebuild option in iPhoto 09 (v. 8.0.2), Rebuild the iPhoto Library Database from automatic backup" makes this tip obsolete.

  • Best way to run script to copy files on login

    I ran the following script last year for the purpoase of copying shortcuts (ex. college webmail, helpdesk, website) to the desktop. I had the shortcuts in a folder on an open share and on login the script would run and copy the shortcuts.
    #bin/bash
    mkdir /Volumes/scripts
    mount -t afp afp://server/scripts /Volumes/scripts
    cp -R /Volumes/scripts/desktop_shortcuts/* ~/Desktop
    umount /Volumes/scripts
    killall Terminal
    This allowed me to add or adjust shortcuts so we would never need to handle adding these manually in the image or after lab deployment. Last year I added it to the "Login Itmes" for the user but this year I'd like to have it run from a server. I've had no luck getting this to wrok from a WGM Server or Profile Manager Server. I tried the "Login Hooks" from the serverside and no luck.
    I can't seem to find a clear document that tells me what the proper scripting procedure is for Mavericks.
    Some posts say used launchd, some say .plist & others applescript.

    I ran the following script last year for the purpoase of copying shortcuts (ex. college webmail, helpdesk, website) to the desktop. I had the shortcuts in a folder on an open share and on login the script would run and copy the shortcuts.
    #bin/bash
    mkdir /Volumes/scripts
    mount -t afp afp://server/scripts /Volumes/scripts
    cp -R /Volumes/scripts/desktop_shortcuts/* ~/Desktop
    umount /Volumes/scripts
    killall Terminal
    This allowed me to add or adjust shortcuts so we would never need to handle adding these manually in the image or after lab deployment. Last year I added it to the "Login Itmes" for the user but this year I'd like to have it run from a server. I've had no luck getting this to wrok from a WGM Server or Profile Manager Server. I tried the "Login Hooks" from the serverside and no luck.
    I can't seem to find a clear document that tells me what the proper scripting procedure is for Mavericks.
    Some posts say used launchd, some say .plist & others applescript.

  • Script for copying files to drop boxes of other Macs

    I don't know much about scripts as yet, but for daily backup purposes
    I would like to copy all new or modified files from various folders
    to the drop boxes of two other Macs (like the old DOS command XCopy)
    and then reset the "modified attributes" (is there something like that at all?)
    of these files.
    A script could do this without the need to always find and select these files
    and to always confirm the messages "You can put items into “Drop Box”,
    but you won’t be able to see them. Do you want to continue?".
    Thanks!

    Here is a short skeleton which doesn't treat subfolders.
    May you check if it do what you want ?
    property sourceFolder : "/Users/home/Documents/Pages/current/"
    property destFolder : "/cr1’s iMac.afpovertcp.tcp.local/cr1's%20Public%20Folder/Drop Box/backup/Documents/Pages/current/"
    on run
    tell application "System Events"
    set dest_folder to path of folder destFolder
    set listeSource to path of disk items of folder sourceFolder
    repeat with sf in listeSource
    if visible of disk item sf then
    tell disk item sf
    set sn to name
    set smd to modification date
    end tell
    if exists disk item sn of folder destFolder then
    set needCopy to modification date of disk item sn of folder destFolder is not smd
    else
    make new file at end of folder destFolder with properties {name:sn}
    set needCopy to true
    end if -- exists disk item
    if needCopy then my copyFile(sf, dest_folder)
    end if -- visible …
    end repeat
    end tell -- System Events
    end run
    on copyFile(sourceFile, targetFolder) (*
    sourceFile is the path to the source file as text,
    dest_folder is the path to the destination folder as text
    newFileName is the name of the file as text
    tell application "Finder"
    duplicate file sourceFile to folder targetFolder with replacing
    end tell
    end copyFile
    Yvan KOENIG (VALLAURIS, France) mercredi 16 décembre 2009 18:33:43

Maybe you are looking for

  • New imac as external monitor for macbook pro?

    I have a 2011 macbook pro that I use for work. I am thinking about buying the new imac for use at home. The question is can I use the imac as an external screen for my mbp? Or do I have to have another external monitor to use for that?

  • How do I autofill user info in a webform/webapp?

    There will be a link across our whole site that says "Report a problem". This should open up a popout window with fields like Operating System Browser & version etc Those I already have set up with js. However, I would like to be able to pre-fill thi

  • SQL not working as Concurrent Program

    Hi I have the following sql pl/sql script which when I run in TOAD, works fine and successfully updates the custom tables declare v_position_id number; v_curr_org_id number; v_new_org_id number; begin select pos.position_id into v_position_id from xx

  • How to upload word documents in iphone?

    Hello, I need to give a talk and I dont have printer... I should use the iphone, but I dont know how to read Word documents in the iphone... Someone can help me?

  • Array concept

    Hi In C program we have concept of array a(i) where we can increment the i value Similarly i want to increment my variable in abap program is tht possible if yes can any one explain me... Thanks in advance. Maya