Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Create user defined directory and copy file to it  (Read 3680 times)

0 Members and 1 Guest are viewing this topic.

corsa

    Topic Starter


    Starter

    Create user defined directory and copy file to it
    « on: November 22, 2008, 07:31:50 PM »
    Hello,

    I have the following case and would like to know if this can be solved using a batch file.

    we have a lot of computers that are mounted into trucks. Every now and then I would like to have a backup of the eventlog. But to save the eventlog into a specified directory the user needs to create a directory, with the registration number of the truck. Is it possible to have a batch file that can first ask the user wich name the directory needs and after that copy the eventlogs to the map with the name that has just been specified by the user?

    Regards,
    Ronald

    Dark Blade

    • Forum Gaming Master


    • Adviser

      Thanked: 24
      • Yes
    • Experience: Experienced
    • OS: Windows XP
    Re: Create user defined directory and copy file to it
    « Reply #1 on: November 22, 2008, 10:10:06 PM »
    Code: [Select]
    @echo off
    set /p Dir=Enter directory name:
    :check
    if exist \%Dir% goto blocked
    md \%Dir%
    ::copying goes here

    goto exit
    :blocked
    cls
    set /p Dir=Directory already exists. Enter new directory name:
    goto check
    :exit

    Ok, that asks for the directory name, then makes it at the root directory (most likely C:\, but you can change where it's going to be saved). It also checks if that directory is already made, and if so asks for a new name. The ::copying goes here is where your copy code goes. I don't know where your eventlogs are located, but just write:
    Code: [Select]
    copy "your eventlog location" \%Dir%

    corsa

      Topic Starter


      Starter

      Re: Create user defined directory and copy file to it
      « Reply #2 on: November 23, 2008, 12:51:28 PM »
      Hello Dark Blade,

      Thanks for the answer. This is working perfect ;D

      Regards,
      Ronald