Toon posts:

conditioneel bestanden verplaatsen

Pagina: 1
Acties:
  • 87 views sinds 30-01-2008

Verwijderd

Topicstarter
Ik wil vanuit een bestaande map met submappen en bestanden bepaalde bestandstypen verplaatsen naar een alternatieve map met dezelfde mapstructuur.

Stel ik heb een map, genaamd map_A met daarin submap1 en submap2. En in submap1 en submap2 zitten ook weer submappen. In alle mappen bevinden jpg, doc, xls, pdf en gif bestanden. Ik zoek een manier om vanuit map_A en alle subdirectories alle xls bestanden te verplaatsen naar een nieuwe map genaamd map_B met daarin dezelfde mappenstructuur als onder map_A. Dit betekent dat alle xls bestanden vanuit bijvoorbeeld map_A\submap1 verplaatst zijn naar map_B\submap1.

Ik wil dit automatiseren middels een script maar ik kan geen commando verzinnen die bestanden verplaatst o.b.v. bestandsextentie en dat dan recursive doet voor alle submappen.

Verwijderd

Eigenlijk is het gewoon een soort van boom doorlopen.

code:
1
2
3
4
5
6
7
8
functie kopieerXls(folder_naam, oude_locatie, nieuwe_locatie) {
    maak_dir(nieuwe_locate + "/" + folder_naam);
    kopieer(oude_locatie + "/" + folder_naam + "/.xls", nieuwe_locatie + "/" + folder_naam);

    for (elke map in deze map) {
        copyXls(map_naam, oude_locatie, nieuwe_locatie);
    }
}


Zoiets ongeveer.

[ Voor 30% gewijzigd door Verwijderd op 20-06-2007 16:32 ]


Verwijderd

als ik me niet vergis doet xcopy vanaf de dos-prompt vrijwel alles wat jij wilt.

  • TheRookie
  • Registratie: December 2001
  • Niet online

TheRookie

Nu met R1200RT

Neem aan dat we het over een windows variant hebben ? zo ja:
start -> run -> cmd
xcopy /?
Copies files and directory trees.

XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
                           [/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]
                           [/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z]
                           [/EXCLUDE:file1[+file2][+file3]...]

  source       Specifies the file(s) to copy.
  destination  Specifies the location and/or name of new files.
  /D:m-d-y     Copies files changed on or after the specified date.
               If no date is given, copies only those files whose
               source time is newer than the destination time.
  /E           Copies directories and subdirectories, including empty ones.
               Same as /S /E. May be used to modify /T.
  /C           Continues copying even if errors occur.
  /I           If destination does not exist and copying more than one file,
               assumes that destination must be a directory.
  /Q           Does not display file names while copying.
  /H           Copies hidden and system files also.
  /R           Overwrites read-only files.
  /K           Copies attributes. Normal Xcopy will reset read-only attributes.
  /O           Copies file ownership and ACL information.
  /X           Copies file audit settings (implies /O).
  /Y           Suppresses prompting to confirm you want to overwrite an
               existing destination file.
  /Z           Copies networked files in restartable mode.

The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line.

ff irrelevante parameters weggelaten, you get the idea ;)
[edit]
@.at: zelfde posttijd :P

Verwijderd

TheRookie schreef op woensdag 20 juni 2007 @ 16:35:
Neem aan dat we het over een windows variant hebben ? zo ja:
start -> run -> cmd
xcopy /?
Copies files and directory trees.

XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
                           [/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]
                           [/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z]
                           [/EXCLUDE:file1[+file2][+file3]...]

  source       Specifies the file(s) to copy.
  destination  Specifies the location and/or name of new files.
  /D:m-d-y     Copies files changed on or after the specified date.
               If no date is given, copies only those files whose
               source time is newer than the destination time.
  /E           Copies directories and subdirectories, including empty ones.
               Same as /S /E. May be used to modify /T.
  /C           Continues copying even if errors occur.
  /I           If destination does not exist and copying more than one file,
               assumes that destination must be a directory.
  /Q           Does not display file names while copying.
  /H           Copies hidden and system files also.
  /R           Overwrites read-only files.
  /K           Copies attributes. Normal Xcopy will reset read-only attributes.
  /O           Copies file ownership and ACL information.
  /X           Copies file audit settings (implies /O).
  /Y           Suppresses prompting to confirm you want to overwrite an
               existing destination file.
  /Z           Copies networked files in restartable mode.

The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line.

ff irrelevante parameters weggelaten, you get the idea ;)
dat zeg ik :)

  • RobIII
  • Registratie: December 2001
  • Niet online

RobIII

Admin Devschuur®

^ Romeinse Ⅲ ja!

(overleden)
Verwijderd schreef op woensdag 20 juni 2007 @ 15:48:
Ik wil dit automatiseren middels een script maar ik kan geen commando verzinnen die bestanden verplaatst o.b.v. bestandsextentie en dat dan recursive doet voor alle submappen.
Voordat wij dat voor je kunnen verzinnen zul je uberhaupt al moeten aangeven wat voor scriptingtaal je beheerst. Gaat het over VBScript? ShellScript? Bash? Weet ik veel...

Als je al zo ver bent kun je vervolgens eens gaan googlen op "<scripttaal> move file" en dan is het enkel nog een kwestie van uitvogelen hoe je condities inbakt, wederom een kwestie van googlen.

Zoals je nu wel duidelijk zal zijn geworden valt of staat je vraag nogal bij welke scripttaal je wil gebruiken en als je daar uit bent blijft er weinig van over behalve een scriptrequest, tenzij je zelf al wat inzet zou hebben getoond.

Lees volgende keer even onze Programming Beleid Quickstart, dan zul je ook concluderen dat je topic niet geheel terecht is in PRG in de vorm zoals het nu is. Mocht je uiteindelijk gaan voor batchfile-achtige oplossingen, kijk dan ook nog even hier: Waar hoort mijn topic?

[ Voor 17% gewijzigd door RobIII op 20-06-2007 16:45 ]

There are only two hard problems in distributed systems: 2. Exactly-once delivery 1. Guaranteed order of messages 2. Exactly-once delivery.

Je eigen tweaker.me redirect

Over mij


  • Creepy
  • Registratie: Juni 2001
  • Laatst online: 30-11 15:10

Creepy

Tactical Espionage Splatterer

Over wat voor taal spreken we hier? "script" is nogal erg generiek namelijk? Als jet om een batch script gaat dan staat je topic nog verkeerd ook ;)

In een willekeurige andere taal lijkt het me een kleine moeite om zelf in elkaar te zetten.

"I had a problem, I solved it with regular expressions. Now I have two problems". That's shows a lack of appreciation for regular expressions: "I know have _star_ problems" --Kevlin Henney

Pagina: 1

Dit topic is gesloten.