SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Non-Member
    Join Date
    Apr 2007
    Posts
    224
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is this .bat file correct?

    I'm trying to create a .bat file that does this:

    for any file that arrives into C:/Input the bat file creates a subfolder in C:/Folders that has the name of that file, like this:

    File XYZ.txt arrives into C:/Input and the bat file creates a subfolder in C:/Folders/ so it appears as C:/Folders/XYZ.txt/

    and then copies xyz.txt file fron C:/Input into C:/Folders/XYZ.txt/ so it appears like this: C:/Folders/XYZ.txt/xyz.txt

    Someone provided this, I ran it unsuccessfully. What am I missing? Thanks.

    @echo off
    set input=c:\input
    set folders=c:\folders
    for /F "delims=. tokens=1" %%i in ('dir %input%\*.* /A-D /B') Do (
    md %input%\%%i
    md %folders%\%%i
    move %input%\%%i.* %folders%\%%i

  2. #2
    SitePoint Enthusiast pyro.699's Avatar
    Join Date
    Jan 2006
    Location
    Canada
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you need to use %~ni to get just the file name. What happens when you run this script?

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2008
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Those %% drive me batty! You need to echo what is in each one of them to see if you are getting the correct info in your variable. DOS really sucks for this sort of thing. If you have to much trouble I recommend Perl instead.
    recipe for food
    hypnosis hypnotic trance
    directory pages


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •