No announcement yet.

BAT file loops, file moving and renaming

  • Filter
  • Time
  • Show
Clear All
new posts

  • BAT file loops, file moving and renaming

    I need help making a bat file that moves files from subdirectories to the main directory, and renaming the files to include day stamps (

    I apologize for the question. At one point in time I was actually a pretty decent C++ and Java coder. 12 years away from the compiler gets you rusty.

    Let's start off with this disclaimer. My client is an idiot and really doesn't understand drag and drop.

    I have a situation where files are coming into a directory from three different sources. Sometimes my client will drag only the file into the directory, other times the folder containing the file will be dragged and dropped.

    I want this scenario from my client: Folder \ files

    I get this usually: Folder \ files and folder(s) \ files

    As I said above, I need to get everything back to the Folder \ files scenario.

    Also, I need to append a day stamp ( on the beginning of the file names.

    It would be nice, but not essential, that I can check for the length of the file name and only append the stamp if the name is 8 chars or shorter (excluding the extension).

    I already have the structures in place to move and back up the file at the end of every day.

    I can do a bunch of this stuff in Java but I am completely clueless with non trivial bat files.

    Thank you guys in advance.


  • #2
    Re: BAT file loops, file moving and renaming

    You don't say which OS you are using, but IMHO investigate powershell -- lots of potential to do this:
    Tom Jones
    MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
    IT Trainer / Consultant
    Ossian Ltd

    ** Remember to give credit where credit is due and leave reputation points where appropriate **


    • #3
      Re: BAT file loops, file moving and renaming

      Thanks for pointing that out. Win Server 2003.