Naming output files in Windows Batch Scripts

<p>Looking for Windows batch script syntax to autonumber,automatically name, and/or randomly name output files to avoidoverwriting output files.</p>

I use this type of functionalithy frequently to save output logs.<BR>Here is a snippet of code that should work. It assumes that you already have the Esscmd script that performs the DBStats call and outputs the log to D:\logs\dbstats.log.<BR><BR>Let me know if you have any questions.<BR><BR>@ECHO OFF<BR>:: ==========================================================<BR>::Filename:     GetDBSTATS.bat<BR>:<img src="i/expressions/face-icon-small-happy.gif" border="0">escription:     Runs DBSTATS and rename outputfile with current date<BR>:: ==========================================================<BR>::<BR>:: Run Esscmd to get dbstats output log d:\logs\dbstats.log<BR>ESSCMD D:\script\getdbstats.ess<BR>::<BR>:: Get Current Date and Time<BR> FOR /F "TOKENS=2" %%i IN ('DATE/T') DO SET FullDate=%%i<BR> SET Month=%fulldate:~0,2%<BR> SET Day=%fulldate:~3,2%<BR> SET Year=%fulldate:~6,4%<BR><BR> FOR /F "TOKENS=1" %%i IN ('TIME/T') DO SET FullTime=%%i<BR> FOR /F "DELIMS=: TOKENS=1" %%i in ('ECHO %fulltime%') DO SET Hour=%%i<BR> FOR /F "DELIMS=: TOKENS=2" %%j in ('ECHO %fulltime%') DO SET Minute=%%j<BR><BR>::<BR>::<BR>RENAME d:\logs\dbstats.log dbstats_%month%_%day%_%year%.log<BR>EXIT<BR>

Similar Messages

  • Hello, How do I tell sql+ to spool output file from windows to Unix server?

    Hello, How do I tell sql+ to spool output file from windows to Unix server?
    I am new to SQL+ and just learned how to spool the file. But file is saved in my local windows enviroment and since it's 2GB in size...I want to spool it directly to another remote unix server.
    Pls answer in detail... I have been to most of the thread and didn't see relevant answer to above question.
    Am I suppose to develope some script which FTP the spool file directly to the server I want to
    or
    i Have to use UTL_FILE Package ?
    Thanks for reply

    You may not be able to...
    SQL*Plus can only spool to the local machine. If you have mapped a directory on the Unix server from your Windows machine, you can specify that directory in your SPOOL command.
    You could telnet to the Unix server, run SQL*Plus there, and spool the file to a local (Unix) directory.
    If the Unix server is also the Oracle database server, you could use the UTL_FILE package rather than using SQL*Plus to spool a file.
    If the Unix server is also an FTP server, you could also FTP the file from your local machine to the server.
    Of course, I would tend to re-examine a requirement to regularly generate a 2 GB text file. It seems likely that there is a better way...
    Justin

  • FTP Receiver File adapter  -- CRLF In output File in Windows environment.

    Hi All,
    Idoc to File : Receiver File adapter.
    I use the endseparator 'nl' and the output file is coming correctly with NFS and It is not working when we are doing with with FTP.
    Tested with NFS (Unix environment)
    I used the endseparator 'nl' and the output file is coming with CRLF.
    Tested with FTP (Windows environment)
    When I tested the same the output file is coming with LF.
    I tried by using the module "SAP XI Sample/ConvertCRLFfromToLF" which will convert from LFToCRLF.But it is serving my purpose.
    Can anyone please suggest how I can get the CRLF in the file while putting in the output directory which is in windows environment.
    Thanks
    Seema

    Do not mention endSeparator in content conversion parameters...by default XI puts newline as endSeparator
    It should work for NFS and FTP on Windows

  • File copying in Batch script and renaming

    HI,
    I am using the below batch script to copy the files from current folder to the specified location.
    (@echo off
    echo copying files to destination
    copy *.eps* \\10.10.14.13\adman\in\displ )
    I am facing 2 problems in the above script..
    1. I am not able to select a particular file and run the script, for e.g if the folder got more (eps) files it copies all the files to the location.
    2. I want to insert my user login name at the end of the each copied file.
    My file name look like (F0#CGDBANG000947532#.eps
    ) copy to F0#CGDBANG000947532#username.eps
    Thanks for all the help

    Hi,
    About this issue, I recommend you consult Script Center forum for professional help:
    http://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?category=scripting
    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or
    learn from your interaction with us. Thank you for your understanding.
    Karen Hu
    TechNet Community Support

  • Windows batch script to recursively copy file/directory of a specific patern

    I would like to copy all pdf files from  directory 'src' and sub-directories 'src/src-sub1' to directory 'trgt', including the directory structure. Any suggestion? thanks!

    Hi,
    Run the command below:
    robocopy x:\src x:\trgt *.pdf /s
    How to write a batch file:
    http://www.wikihow.com/Write-a-Batch-File
    Andy Altmann
    TechNet Community Support

  • Output file location for batch printing

    Hi all,
    We have a current implementation of Oracle Documaker for our LOB. What we do is run a .BAT file that runs the GEN* brothers (gentnw32, gendaw32, and genptw32). This then uses the XML defined in the DATA segment of the fsisys INI file. This prints out multiple PDFs for us depending on the contents of the XML.
    This workspace is a hand-me-down and works as is but with the new requirements, I need to direct the PDFs to a specific directory. Currently, it places them in the root folder/PRINT. This setup is not found on any line in the fsisys or fsiuser files. Is there a configuration I can make to have Documaker place it someplace else? Thanks!
    We are using Documaker Studio Version 12.2.0.21451 Build Aug 8 2013. The workspace however was created with an older version (uses an MRL files rather than an ODBC connection)

    Your question about scripting was as follows:
    Can someone give me a brief explanation of what the lines: "SetGVM("PrtName001" ,file_name ,,"C",254)", "HaveGVM("PRTName001")", and "GVM("PRTName001")" do? I am confused since a DAL script named PDF_NAME is run when I execute GenData but it is not called in any line in the INI file (where is it called). It sets the GVM seen above but it does not reflect immediately when GV1 script and GV2 script are called in GenPrint. However, they are reflected when GV1 is run after POSTTRANSDAL for Batch1. Sorry about the confusing question. These three lines are found in separate DAL scripts.
    First, anytime you want a basic explanation for most DAL functions, I would point you to the help. If you have the script open in the Triggers/Script manager in DMStudio and click on the function name, you should see the help panel reflect the function you click. You can also simply press F1 and find all the DAL help and browse it at your leisure.
    GVM means Global Variable Member (or something like that). These are variables created and used during the server process - GenTrn, GenData, and GenPrint. Each program is responsible for creating the GVMs that it will used and only live within that program. The only way for GVMs to get "passed" to the next program is if these were written to a file that is subsequently loaded by the next program. For instance, the Gendata step creates the Batch (BCH) files mentioned in the other post. The content written to each recipient record in the BCH file is (typically) taken from GVMs. Then when GenPrint loads a particular batch record, those column values are again turned into GVMs. You may not have needed that lesson, but I thought it might be helpful in explaining the DAL rules you questioned.
    HAVEGVM() is used to query whether a GVM actually exists. If it doesn't exist, then there is certainly no way you can get a value from it.
    SETGVM() is used to 1) assign a value to an existing GVM; and 2) optionally create a new GVM if it does not already exist. In your case, the parameters to the SetGVM would appear to be allowing the variable creation identifying that it will hold character ("C") content with a max length of 254 bytes.
    GVM() is a function that returns the value currently assigned to the named GVM.
    So you see that your DAL script is capable of creating a GVM if it does not already exist. From what information you have, I don't know whether that is needed or not. It really depends upon your implementation.
    Your PORT= statements define to run an associated script and that ultimately must be returning the actual starting name to use for that output. Assuming this is coming from GVM values, there's not enough information here to say where they are coming from. These could be taken from a column defined in your BCH files; or could be determine by some field value hidden (or otherwise contained) in your transaction data; or might be queried or created by some other scripting method.

  • Catch procedure error in batch script

    Hi,
    I am calling the procedure inside a loop in a windows batch script.
    Is there any way i can catch the oracle exception ora- errors ? in the batch script.
    Thx.

    Batch file cannot catch errors that are thrown by oracle procedures.
    you can do some work around.
    1. push the errors to a log file (text file) from the procedure.
    2. once the procedure is complete, you can read for a specific text in the log file from Batch file. and if you find that error had occurred then do your stuff.
    Regards,
    Prazy

  • How to call a batch script from DI?

    Hi All,
    I'm new to DI/DS and would like to know is there a way to call a batch sciprt (.bat file) in DI?
    What I try to do is,
    1.call a batch script to move source files from a file server to the source folder before kicking off the data flow
    2. once the data flow is completed, call a batch script to move the processed source files to the achive folder.
    In other ETL tool like informatica it can be done via the command task, is there something similar in DI?
    Any help would be appreciated.
    Regards
    BL

    Thanks Suneer.
    Just want to clarify, when I create the script task in the work flow, should I put the path of my batch file or the batch script itself in?
    e.g., my batch script is movefile.bat under folder C:\Script,
    and the command is:  move /Y "C:\Input\*.*". "C:\Archive\".
    in the script task, should I put
    exec('cmd', 'C:\Script\movefile.bat')
    or
    exec('cmd', 'move /Y "C:\Input\*.*". "C:\Archive\".')
    Thanks again for your help
    Regards,
    BL

  • How to checkout from the batch script?

    Hello All !
    Does anybody knows how to maintain versioned files with the batch scripts? Particularly I'm talking about doing a checkout/checkin operations. Are any command-line utilities available? Is it possible at all?
    Regards, Sergey.

    you can get entire table script
    select dbms_metadata.get_ddl('TABLE','TABLE_NAME','SCHEMANAME') from dual;
    IT is not possible to get only the partition script
    As it is a part of table definition.
    You can also use the third party tool like 'TOAD' to get the script also.

  • ** Is it possible to run a windows .bat script job from ODI between server?

    Hello Friends,
    We have ODI 10.1.3.5 on a Win2003 Server.
    Have a windows Batch script job .bat(this is a related to a different program - DRM) on a different Windows 2003 server...is it possible to execute .bat job thru ODI between servers?
    Appreciate your suggestions...
    Thanks.

    Hi AJ,
    Here are more details:
    Server-A: ODI Server (Win2003)
    Server-B: Oracle DRM Server (Win2003)
    Server-C: ODI scheduler agent is installed (Linux)
    We have a .bat batch script job on Server-B which we are planning to run from Server-A (as part of the ODI package execution flow)
    This .bat job exports the DRM hierarchy data to a table that ODI uses to process next steps.
    So, you are suggesting to install ODI agent on Server-B? If we do that...not sure if there be issues if we have to run the package with other scenario's (interfaces/Procedures) that refer agent isntalled in Server-C??
    Any feedbacks are appreciated!!
    Thanks

  • [CS3] I have never been able to get this right: Batch/Droplet and output file naming??????

    Hi,
    The situation:
    I need to convert a folder of PDF's to PNG format.
    My process:
    I create an action by recording my "actions" based on one of the said PDF's.
    Problem:
    When batching and/or processing via a droplet (created from action I created from above), the output file name is ALWAYS the EXACT name of the file I used when I created my action!!! Why? I have tried everything... Why is it so hard for Photoshop to batch a file and use the file name of the current file being batched (and not the name of the original file that the action was created from)???
    Please help!
    I feel like such a dunce... I am sure the answer is staring me right in the face.
    Many thanks in advance!!!
    Cheers,
    Micky

    Hi Conrad!
    Thanks for the help, I greatly appreciate your time. :)
    Sorry for my delayed reply.
    I never touched the file name for the save as dialog box.
    I have use PS for many years, and I have never been able to get the file name to stay the same as the file being processed. :(
    My boss even, he is a beta tester of future versions of Adobe products, and he could not get it to work...
    It only worked for me/us when appending a digit to the end of the file name. Not an optimal solution, but it works. ;)
    @Foot, I am glad this thread was helpful! :D
    Have a great day all!
    Cheers,
    Micky

  • Batch / script file to start /stop sap server

    Hi,
       I would like to start/stop SAP server using batch file (in windows). I need this, whenever we have to shutdown the server and restart of the server, so that SAP will automatically shutdown and restart using batch files while server restart cases? If anyone knows, please let me know. Thanks,
    Regards,
    Sundar.

    target of the 700 sapstartsrv improvement was to deliver identical functionality on all SAP platforms. As the DCOM programing model is only available on Windows platforms sapstartsrv.exe was enhanced by the WEB-Service interface and is available now on Unix too.
    The DCOM SAPControl interface of sapstartsrv.exe is still existing, but only on Windows. Here you can use VB Script or any other programming language able to handle DCOM objects to write your own programs / scripts to interact with the SAPControl.
    sapcontrol.exe is a command line program available since 700 which enables you control over nearly all functions of the sapstart service.
    Even it has the same name as the DCOM interface it' something completly different.
    regards
      Peter
    PS: sapcontrol syntax
    usage: sapcontrol [
                       -prot GSOAP_HTTP| http using gsoap build in sockets (default)
                             NI_HTTP|    http using SAP NI sockets (prefer Unix domain sockets)
                             NI_HTTPS|   https using SAP NI sockets (prefer Unix domain sockets)
                             WINHTTP|    http using Windows winhttp
                             WINHTTPS|   https using Windows winhttp
                             PIPE        Windows named pipes
                       [-user <user> <password>] OS user and password for Webservice authentication
                       [-repeat <N> <D>]         Repeat Webmethod call <N> times (-1=forever) with <D> sec delay
                        -format list|            List output format (default)
                                script           Script output format
                       [-host <hostname>]        Host to connect to (default: localhost)
                       -nr <instance nr.>        SAP Instance number to connect to
                       -function <Webmethod> [parameter list]
    Webmethods: Start
                Stop [softtimeout sec]
                Shutdown
                RestartInstance [softtimeout sec]
                StopService
                StartService <SID>
                RestartService
                ParameterValue [<parameter>]
                GetStartProfile
                GetTraceFile
                GetAlertTree
                GetAlerts
                GetEnvironment
                GetVersionInfo
                GetQueueStatistic
                GetProcessList
                GetInstanceProperties
                ListDeveloperTraces
                ReadDeveloperTrace <filename> <filesize>
                ListLogFiles
                ReadLogFile <filename> [<filter> [<language> [<maxentries> [<cookie>]]]]
                AnalyseLogFiles [<severity 0-2>] [<maxentries>] [<starttime YYYY MM DD HH:MM:SS> <endtime YYYY MM DD HH:MM:S
    S>]
                OSExecute <command> <async> <timeout> <protocolfile>
                SendSignal <pid> <signal>
                GetSystemInstanceList
                StartSystem [ALL|SCS|DIALOG|ABAP|J2EE|LEVEL <level> [<waittimeout sec>]]
                StopSystem [ALL|SCS|DIALOG|ABAP|J2EE|LEVEL <level> [[<waittimeout sec>] [softtimeout sec]]]
                RestartSystem [ALL|SCS|DIALOG|ABAP|J2EE|LEVEL <level> [[<waittimeout sec>] [softtimeout sec]]]
                AccessCheck <function>
                ABAPReadSyslog
                ABAPReadRawSyslog
                ABAPGetWPTable
                J2EEControlProcess <processname> <function>
                J2EEGetProcessList
                J2EEGetThreadList
                J2EEGetSessionList
                J2EEGetCacheStatistic
                J2EEGetApplicationAliasList
                J2EEGetVMGCHistory
                J2EEGetVMHeapInfo
                StartWait <timeout sec> <delay sec>
                StopWait <timeout sec> <delay sec>
                WaitforStarted <timeout sec> <delay sec>
                WaitforStopped <timeout sec> <delay sec>
    Exitcode: 0: Last Webmethod call successfull
              1: Last Webmethod call failed, invalid parameter
              2: StartWait, StopWait, WaitforStarted, WaitforStopped timed out
              3: GetProcessList succeeded, all processes running correctly
              4: GetProcessList succeeded, all processes stopped
    Security: Trusted connects without user and password check are possible through
              Unix domain socket or Windows named pipes. Protected webmethods like
              Start or Stop require a trusted connection or OS user and password
              authentication.

  • Find and replace string in a file using batch script

    I am writing a batch script to replace " ", with " ". The below code works but it prefixes each line with the line number and :.
    It is the last part of the line that I am trying to replace.
    E.g.
    " ","BALANCE_SHEET ","ASSETS ","03","LEVEL_2 ",Asset Accounts," ",
    To be replaced as
    " ","BALANCE_SHEET ","ASSETS ","03","LEVEL_2 ",Asset Accounts," "
    Code:
    @echo off &setlocal
    set "search=" ","
    set "replace=" ""
    set "textfile=Build_Accounts_Plan_Source.txt"
    set "newfile=Build_Accounts_Plan_Source_new.txt"
    (for /f "delims=" %%i in ('findstr /n "^" "%textfile%"') do (
    set "line=%%i"
    setlocal enabledelayedexpansion
    set "line=!line:%search%=%replace%!"
    echo(!line!
    endlocal
    ))>"%newfile%"
    type "%newfile%"
    Output:
    3:" ","BALANCE_SHEET ","ASSETS ","03","LEVEL_2 ",Asset Accounts," "
    Regards,
    Ragav.

    Did you retype the code or did you use copy/paste? Retyping is not a good idea.
    You can do this to find the cause of the problem:
    Run the modified code below.
    Use notepad.exe to open the file TempVBS.vbs in your %temp% folder.
    Mark & copy the code, then paste it into your reply.
    @echo off
    set "textfile=Build_Accounts_Plan_Source.txt"
    set "newfile=Build_Accounts_Plan_Source_new.txt"
    set Scr="%temp%\TempVBS.vbs"
    (  echo Set oFSO = CreateObject("Scripting.FileSystemObject"^)
       echo Set oInput = oFSO.OpenTextFile(WScript.Arguments(0^), 1^)
       echo sData = Replace(oInput.ReadAll, "," ^& VbCrLf, VbCrLf^)
       echo Set oOutput = oFSO.CreateTextFile(WScript.Arguments(1^), True^)
       echo oOutput.Write sData
       echo oInput.Close
       echo oOutput.Close) > %Scr%
    cscript //nologo %Scr% %textfile% %newfile%

  • Is there any command in windows batch file similar to the unix grep command

    Hi,
    I have a batch file which will return status of the Database to a file ex: "OPEN". Now I want to read this output file and check for the "OPEN" string from another batch file. any suggestions?. This is similar to "grep" command in unix. I want this to be done in windows batch file.
    This is my actual batch file
    rem -- Description: Check whether the Database is UP
    rem -- Usage:
    rem -- ORACLE_SID is input parameter for the file
    rem --
    rem --start of batch file
    @echo off
    set ORACLE_SID=%1
    echo connect plp/ltd1plp@%1
    echo set cmdsep on
    echo set cmdsep '"'; --"
    echo set term on
    echo spool c:/status_log.log
    echo select status from v$instance;
    echo spool off
    ) | sqlplus /nolog
    rem --end batch file
    Thanks.

    The same link from [google cache|http://209.85.229.132/search?q=cache:EJrm9tgj0a8J:www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/find.mspx+windows+find&cd=1&hl=en&ct=clnk&client=opera]. Also you can use help:
    find /?

  • I can't open batch files in windows 8.1

    I am trying to run a batch file in windows 8.1, when i run the batch file runs at first but closes so fast that you can't see its contents, you can't even see if its doing what you tell it to. Since the file does run but closes fast, i thought of adding
    pause. Adding pause did not fix the problem. I am not sure if i have to change my keys on regedit, or i have some kind of malicious software  that needs to be fixed  ( I think i have no malicious software, i  have run security scan many times
    nothing showed up, I had a Trojan horse, Trojan.Gen2, long time ago but the Trojan got quarantined?) I originally had windows 8 but upgraded to windows 8.1. 
    Help Please! I don't Know what to do!!!

    Hi Glogikon,
    "I am trying to run a batch file in windows 8.1, when i run the batch file runs at first but closes so fast that you can't see its contents, you can't even see if its doing what you tell it to."
    According to my experience ,it is a normal symptom .Did the bat file run well before ?
    Have you tried to run the command one by one in the bat file from a command line ?Have you tried to run the other bat files which including a output to have a check ?
    If it is possible ,please post the command of the bat file here .We will make a test for you .
    To check whether the bat run well ,this link may be useful:
    check if command was successfull in a batch file
    http://stackoverflow.com/questions/14691494/check-if-command-was-successfull-in-a-batch-file
    " I think i have no malicious software, i  have run security scan many times nothing showed up,"
    We can try to work with the following official free tool to have a check .It is recommended to run it in a safe mode to improve the quality of the scanning.
    Malicious Software Removal Tool
    http://www.microsoft.com/security/pc-security/malware-removal.aspx
    NOTE: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites.
    Best regards
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact [email protected]

Maybe you are looking for

  • Locked PCI/AGP

    I have the K7N2-Delta L. Is the PCI/AGP bus speed locked automatically or do I have to change settings for these items in bios?  I oc'd fsb to 200Mhz w/333Mhz ram runs good but Ghost Recon has graphic noise bars and blips in sound when I run it.  I h

  • EHP5 - when will it be available on general release, anyone installed it?

    Hi SDNers, Does anyone know when EHP5 will be released? I see that Note 1171344 SEM-BCS in the context of SAP ERP 6.0 EHP was updated in June with more information on EHP5 features. Does anyone know when it will be on general release? If anyone is cu

  • White Screen Upon Pause

    Video and everything else works fine, but whenever I pause the viewer, the viewer goes white. Any suggestions?

  • How to install missing kaleidoscope effect

    I'm trying to edit a Final Cut project created by a friend who has the same version of FCStudio that I do: 5.1.4 I copied the project and media files onto my computer, but when I try to render it I get the message: "The following effects could not be

  • I don't have intel based on my mac

    I need to upgrade my Mac OS X  version 10.5.8 to snow  leopard iOS there any help there ?please