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

Author Topic: Read Characters from filename and move the file to a subfolder  (Read 2629 times)

0 Members and 1 Guest are viewing this topic.

hrm

  • Guest
Hi,
I need to read a filename and based on some characters, decide to move the file in appropriate folders. Here is an example:

gibberish_Water_Cloud.abc
gibb_Water_Sky.abc
moregibb_Air_Sky.abc
stillmorgib_Air_Cloud.abc

I need to move these into following four folders that already exist:
Water_Cloud
Water_Sky
Air_Sky
Air_Cloud

Any help will be appreciated.
Thanks


macdad-



    Expert

    Thanked: 40
    Re: Read Characters from filename and move the file to a subfolder
    « Reply #1 on: April 29, 2009, 11:21:37 AM »
    This should help, make sure you put it in the same folder as the abc files.

    Code: [Select]
    @echo off
    for /f %%a in (*Water_Cloud.abc) do move %%a Water_Cloud\%%a
    for /f %%a in (*Water_Sky.abc) do move %%a Water_Sky\%%a
    for /f %%a in (*Air_Sky.abc) do move %%a Air_Sky\%%a
    for /f %%a in (*Air_Cloud.abc) do move %%a Air_Cloud\%%a

    Hope this helps
    ,Nick(macdad-)
    If you dont know DOS, you dont know Windows...

    Thats why Bill Gates created the Windows NT Family.

    gh0std0g74



      Apprentice

      Thanked: 37
      Re: Read Characters from filename and move the file to a subfolder
      « Reply #2 on: April 29, 2009, 07:27:49 PM »
      no need to use the for loop.
      Code: [Select]
      move *Water_Sky Water_Sky

      macdad-



        Expert

        Thanked: 40
        Re: Read Characters from filename and move the file to a subfolder
        « Reply #3 on: April 30, 2009, 06:21:14 AM »
        Oh well...either works
        If you dont know DOS, you dont know Windows...

        Thats why Bill Gates created the Windows NT Family.

        gh0std0g74



          Apprentice

          Thanked: 37
          Re: Read Characters from filename and move the file to a subfolder
          « Reply #4 on: April 30, 2009, 07:36:12 AM »
          yes, either works. but ..............