Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Consolidate files into a single folder
Message
De
17/07/2011 18:16:41
 
 
À
17/07/2011 15:13:02
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Divers
Thread ID:
01518403
Message ID:
01518407
Vues:
98
This message has been marked as the solution to the initial question of the thread.
Hi Victor, would you try this?
CLEAR ALL
SET SAFETY OFF

CREATE CURSOR csrFiles (fname C(128))
GetFilesInFolder("d:\myprojects\images")

IF RECCOUNT("csrFiles") > 0
  SELECT csrFiles
  LOCATE
  BROWSE NOWAIT
  m.lcDir = GETDIR("","Folders:", "Select destination folder", 64)
  IF !EMPTY(m.lcDir)
    m.lcDir = ADDBS(LOWER(m.lcDir))
    SCAN
      IF JUSTEXT(fname) == "png"
        COPY FILE (fname) TO (m.lcDir + CHRTRAN(SUBSTR(fname, 4), "\", "_"))
      ENDIF
    ENDSCAN
  ENDIF
ENDIF

USE IN csrFiles

RETURN

PROCEDURE GetFilesInFolder(tcFolder)
  LOCAL ARRAY laFiles[1]
  LOCAL lnFileCount, lnIndex, lcFile
  m.tcFolder = ADDBS(m.tcFolder)
  m.lnFileCount = ADIR(laFiles, m.tcFolder+"*.*", "D", 1)
  FOR m.lnIndex = 1 TO m.lnFileCount
    m.lcFile = TRIM(m.laFiles[lnIndex, 1])
    IF (AT("D", m.laFiles[lnIndex, 5]) > 0)
      IF !INLIST(m.lcFile, ".", "..")
        GetFilesInFolder(m.tcFolder + m.lcFile)
      ENDIF
    ELSE
      INSERT INTO csrFiles VALUES (m.tcFolder + m.lcFile)
    ENDIF
  ENDFOR
ENDPROC
Regards,
Ony
Regards,
Ony
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform