begin process at 2010 03 21 15:10:41
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Fichier / Disque

 > PROGRAMME POUR RENOMMER PLUSIEUR FICHIER

PROGRAMME POUR RENOMMER PLUSIEUR FICHIER


 Information sur la source

Note :
Aucune note
Catégorie :Fichier / Disque Classé sous :renommer, chaine, filelistbox, replace, checkbox Niveau :Débutant Date de création :29/12/2007 Date de mise à jour :01/01/2008 15:10:41 Vu / téléchargé :6 789 / 287

Auteur : micbristol

Ecrire un message privé
Commentaire sur cette source (6)
Ajouter un commentaire et/ou une note

 Description

J'ai fait ce programme pour renommer les fichiers (a l'origine les mp3).
Il permet d'enlever , rajouter des caracteres a un endroit choisi dans la chaines.
Le programme est quasiment fini mais mon cerveau avait besoin d'un break, donc quelques bug restent.
Comme le rafraichissement auto de la liste de selection ou le message d'erreur qui n'apparait pas si "toutes les cases" n'ont pas été cochées.
Je suis assez debutant donc n'hesitez pas a me critiquer ou me dire comment j'aurais pu faire mieux.Toutes les remarques seront bienvenues

Tchô

Source

  • Public selectedfile As String
  • Public Valtextaddremo As String
  • Public texttoremove As String
  • Private Sub Checkadd_Click()
  • 'if we clic on add, remove must come off
  • If Checkadd.Value = Checked Then
  • Checkremove.Value = Unchecked
  • End If
  • End Sub
  • Private Sub Checkremove_Click()
  • 'if we clic on remove, add must come off
  • If Checkremove.Value = Checked Then
  • Checkadd.Value = Unchecked
  • End If
  • End Sub
  • Private Sub Checkafter_Click()
  • 'if we clic on after, before must come off
  • If Checkafter.Value = Checked Then
  • Checkbefore.Value = Unchecked
  • End If
  • End Sub
  • Private Sub Checkbefore_Click()
  • 'if we clic on before, after must come off
  • If Checkbefore.Value = Checked Then
  • Checkafter.Value = Unchecked
  • End If
  • End Sub
  • Private Sub Command1_Click()
  • 'erase the textaddremove textbox
  • Textaddremove.Text = ""
  • End Sub
  • Private Sub Command2_Click()
  • 'erase the Textpos textbox
  • Textpos.Text = ""
  • End Sub
  • Private Sub Command3_Click()
  • 'copy text1 selection
  • Form1.Text1.SetFocus
  • SendKeys "^C"
  • End Sub
  • Private Sub Command4_Click()
  • 'paste the selection into textaddremove textbox
  • Form1.Textaddremove.SetFocus
  • SendKeys "^V"
  • End Sub
  • Private Sub Command5_Click()
  • 'paste the selection into textpos textbox
  • Form1.Textpos.SetFocus
  • SendKeys "^V"
  • End Sub
  • Private Sub Commandaddall_Click()
  • 'add all the files into file1 to list1
  • For i = 0 To File1.ListCount - 1
  • List1.AddItem File1.List(i)
  • Next
  • End Sub
  • Private Sub Commandaddorremove_Click()
  • 'we replace (textpos) by (textpos + textaddremove)
  • If Checkadd.Value And Checkbefore.Value = Checked Then
  • Textposition = Textaddremove & Textpos
  • Textposition2 = Textpos
  • GoTo changename
  • ElseIf Checkremove.Value And Checkbefore.Value = Checked Then
  • Textposition = Textpos
  • Textposition2 = Textaddremove & Textpos
  • GoTo changename
  • ElseIf Checkadd.Value And Checkafter.Value = Checked Then
  • Textposition = Textpos & Textaddremove
  • Textposition2 = Textpos
  • GoTo changename
  • ElseIf Checkremove.Value And Checkafter.Value = Checked Then
  • Textposition = Textpos
  • Textposition2 = Textpos & Textaddremove
  • ElseIf Checkadd.Value Or Checkremove.Value Or Checkbefore.Value Or Checkafter.Value = Unchecked Then
  • MsgBox "Cochez toutes les cases..."
  • End If
  • changename:
  • For i = 0 To List1.ListCount - 1
  • selectedfileC = List1.List(i)
  • 'on cherche dans (selectedfileC) le (textposition2) qu'on va remplacer par (textposition), that will give us newname1010
  • newname1010 = Replace(selectedfileC, Textposition2, Textposition)
  • 'i use f and g as string cuz the fonction (name) wont work with such complexe expressions
  • f = Dir1.Path & "\" & selectedfileC
  • g = Dir1.Path & "\" & newname1010
  • Name f As g
  • Next
  • File1.Refresh
  • End Sub
  • Private Sub Commandaddselected_Click()
  • 'i copy the selection in file1 to list1
  • Dim i As Integer
  • If File1.ListIndex = -1 Then Exit Sub
  • For i = File1.ListCount - 1 To 0 Step -1
  • If File1.Selected(i) = True Then
  • List1.AddItem File1.List(i)
  • End If
  • Next i
  • End Sub
  • Private Sub Commandclearlist_Click()
  • List1.Clear
  • End Sub
  • Private Sub Commandclearselected_Click()
  • 'same as copy into list1 but this is to remove a selection from a list
  • Dim i As Integer
  • If List1.ListIndex = -1 Then Exit Sub
  • For i = List1.ListCount - 1 To 0 Step -1
  • If List1.Selected(i) = True Then
  • List1.RemoveItem (i)
  • End If
  • Next i
  • End Sub
  • Private Sub Commandundertospaces_Click()
  • 'same as above, i search (_) into (selectedfileB) and replace it with ( )
  • For i = 0 To List1.ListCount - 1
  • selectedfileB = List1.List(i)
  • newnameB = Replace(selectedfileB, "_", " ")
  • d = Dir1.Path & "\" & selectedfileB
  • e = Dir1.Path & "\" & newnameB
  • Name d As e
  • Next
  • File1.Refresh
  • End Sub
  • Private Sub Drive1_Change()
  • Dir1.Path = Drive1.Drive
  • End Sub
  • Private Sub Dir1_Change()
  • File1.Path = Dir1.Path
  • End Sub
  • Private Sub List1_Click()
  • 'i copy the name of the file i clic on into the text1box for the user to use it for copying and pasting
  • Text1.Text = List1.Text
  • End Sub
  • Private Sub onlymp3_Click()
  • 'i set file1 to show only the files.mp3 if (onlymp3) is checked, else it shows *.*
  • If onlymp3.Value = 1 Then
  • File1.Pattern = "*.mp3"
  • Else
  • File1.Pattern = "*.*"
  • End If
  • End Sub
  • Private Sub Commandexit_Click()
  • End
  • End Sub
  • Private Sub Textaddremove_Change()
  • Textaddremove = Textaddremove.Text
  • End Sub
  • Private Sub Textpos_Change()
  • Textpos = Textpos.Text
  • End Sub
Public selectedfile As String
Public Valtextaddremo As String
Public texttoremove As String
Private Sub Checkadd_Click()
'if we clic on add, remove must come off
    If Checkadd.Value = Checked Then
    Checkremove.Value = Unchecked
    End If
End Sub
Private Sub Checkremove_Click()
'if we clic on remove, add must come off
    If Checkremove.Value = Checked Then
    Checkadd.Value = Unchecked
    End If
End Sub
Private Sub Checkafter_Click()
'if we clic on after, before must come off
    If Checkafter.Value = Checked Then
    Checkbefore.Value = Unchecked
    End If
End Sub
Private Sub Checkbefore_Click()
'if we clic on before, after must come off
    If Checkbefore.Value = Checked Then
    Checkafter.Value = Unchecked
    End If
End Sub
Private Sub Command1_Click()
'erase the textaddremove textbox
    Textaddremove.Text = ""
End Sub
Private Sub Command2_Click()
'erase the Textpos textbox
    Textpos.Text = ""
End Sub
Private Sub Command3_Click()
'copy text1 selection
    Form1.Text1.SetFocus
    SendKeys "^C"
End Sub
Private Sub Command4_Click()
'paste the selection into textaddremove textbox
    Form1.Textaddremove.SetFocus
    SendKeys "^V"
End Sub
Private Sub Command5_Click()
'paste the selection into textpos textbox
    Form1.Textpos.SetFocus
    SendKeys "^V"
End Sub
Private Sub Commandaddall_Click()
'add all the files into file1 to list1
    For i = 0 To File1.ListCount - 1
    List1.AddItem File1.List(i)
    Next
End Sub
Private Sub Commandaddorremove_Click()
'we replace (textpos) by (textpos + textaddremove)
    If Checkadd.Value And Checkbefore.Value = Checked Then
    Textposition = Textaddremove & Textpos
    Textposition2 = Textpos
    GoTo changename
    ElseIf Checkremove.Value And Checkbefore.Value = Checked Then
    Textposition = Textpos
    Textposition2 = Textaddremove & Textpos
    GoTo changename
    ElseIf Checkadd.Value And Checkafter.Value = Checked Then
    Textposition = Textpos & Textaddremove
    Textposition2 = Textpos
    GoTo changename
    ElseIf Checkremove.Value And Checkafter.Value = Checked Then
    Textposition = Textpos
    Textposition2 = Textpos & Textaddremove
    ElseIf Checkadd.Value Or Checkremove.Value Or Checkbefore.Value Or Checkafter.Value = Unchecked Then
    MsgBox "Cochez toutes les cases..."
    End If
changename:
    For i = 0 To List1.ListCount - 1
    selectedfileC = List1.List(i)
'on cherche dans (selectedfileC) le (textposition2) qu'on va remplacer par (textposition), that will give us newname1010
    newname1010 = Replace(selectedfileC, Textposition2, Textposition)
'i use f and g as string cuz the fonction (name) wont work with such complexe expressions
    f = Dir1.Path & "\" & selectedfileC
    g = Dir1.Path & "\" & newname1010
    Name f As g
    Next
    File1.Refresh
    

    
    
    
End Sub
Private Sub Commandaddselected_Click()
'i copy the selection in file1 to list1
    Dim i As Integer
    If File1.ListIndex = -1 Then Exit Sub
    For i = File1.ListCount - 1 To 0 Step -1
    If File1.Selected(i) = True Then
    List1.AddItem File1.List(i)
    End If
    Next i
End Sub
Private Sub Commandclearlist_Click()
    List1.Clear
End Sub
Private Sub Commandclearselected_Click()
'same as copy into list1 but this is to remove a selection from a list
    Dim i As Integer
    If List1.ListIndex = -1 Then Exit Sub
    For i = List1.ListCount - 1 To 0 Step -1
    If List1.Selected(i) = True Then
    List1.RemoveItem (i)
    End If
    Next i
End Sub
Private Sub Commandundertospaces_Click()
'same as above, i search (_) into (selectedfileB) and replace it with ( )
     For i = 0 To List1.ListCount - 1
     selectedfileB = List1.List(i)
     newnameB = Replace(selectedfileB, "_", " ")
     d = Dir1.Path & "\" & selectedfileB
     e = Dir1.Path & "\" & newnameB
     Name d As e
     Next
     File1.Refresh
End Sub
Private Sub Drive1_Change()
    Dir1.Path = Drive1.Drive
End Sub
Private Sub Dir1_Change()
    File1.Path = Dir1.Path
End Sub
Private Sub List1_Click()
'i copy the name of the file i clic on into the text1box for the user to use it for copying and pasting
    Text1.Text = List1.Text
End Sub
Private Sub onlymp3_Click()
'i set file1 to show only the files.mp3 if (onlymp3) is checked, else it shows *.*
    If onlymp3.Value = 1 Then
    File1.Pattern = "*.mp3"
    Else
    File1.Pattern = "*.*"
    End If
End Sub
Private Sub Commandexit_Click()
    End
End Sub
Private Sub Textaddremove_Change()
    Textaddremove = Textaddremove.Text
End Sub
Private Sub Textpos_Change()
    Textpos = Textpos.Text
End Sub


 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 Historique

01 janvier 2008 15:10:41 :
voici le .zip

 Sources de la même categorie

Source avec Zip Source avec une capture TRAITEMENT DES NOMS DE FICHIERS. par artgile
Source avec Zip Source .NET (Dotnet) GESTION DE PARC AUTOMOBILE AVEC SÉRIALISATION par guyr07
Source avec Zip Source avec une capture Source .NET (Dotnet) FICHIERS_CACHÉS_LECTURE_SEULE par Le Pivert
Source avec Zip Source avec une capture CHANGEUR D'ICONES par djgab21
Source .NET (Dotnet) DIRECTDISKACCESS par XelectroX

 Sources en rapport avec celle ci

Source avec Zip Source avec une capture ALTERNATIVE À LA FUNCTION VBA OU VB REPLACE (JUSQU'À 10 FOI... par vicosta
Source avec Zip Source avec une capture Source .NET (Dotnet) DOSSIEREXPRESSO par OhTofocus
Source avec Zip Source avec une capture Source .NET (Dotnet) MM CHECKBOX .NET V.2009 V4 par claudetom
Source avec Zip Source avec une capture Source .NET (Dotnet) MM CHECKBOX .NET V.2009 par Mayzz
SUPPRESSION DE CARACTÈRES DANS UN STRING par Jean_Elens

Commentaires et avis

Commentaire de Sechaud le 30/12/2007 09:43:20

micbristol tu devrais mettre un zip pour que l'on puisse tester ton programme sans avoir à tout refaire.
Je te signale que sur VBFrance, on trouve un programme similaire, fait par mimiZanzan,qui marche très bien:
http://www.vbfrance.com/codes/MODIFICATIONS-NOM-FICHIERS-DANS-MEME-REPERTOIRE_42629.aspx

Commentaire de micbristol le 01/01/2008 15:08:22

hello SECHAUD
il me semblait avoir inclu le fichier .zip mais apparement non, le probleme c'est que je ne sais pas comment faire pour l'ajouter maintenant.
le programme de mimiZanzan est legerement different mais tres bien concu. il m'aurait eviter des heures de travaille si je l'avais vu auparavant hehe.

Commentaire de chris188 le 01/01/2008 15:18:27

Hello,

Pour renommer les MP3, un super programme gratuit existe : MediaTagger.

Pour ta source, n'hésite pas à nommer les contrôles correctement dès le départ, tu ne le regreteras pas...
ex: Command5_Click() => bCopierSelection_Click(), il suffit de nommer le bouton dès que tu le crées.
Aussi l'indentation est conseillée, et oublier les Goto (surement à remplacer par Select Case)

A+

Commentaire de mimiZanzan le 01/01/2008 16:51:00

Merci à Sechaud d'avoir cité mon code.
J'en profite pour signaler que je viens de faire une mise à jour du programme.

Commentaire de Renfield le 02/01/2008 08:27:21 administrateur CS

nul besoin de ces GoTo changename
évite aussi les SendKeys... tu peux tout a fait uiliser l'objet Clipboard

Commentaire de micbristol le 02/01/2008 12:40:09

merci a vos commentaires, mais essayez d'etre plus precis avec des exemples (je vous avais prevenu je suis debutant...:s)
quoi que c'est aussi a moi de chercher un peu...
la raison pour laquelle mes noms de Command sont un peu "inexplicit", c'est que a l'origine mon programme avait pas du tout la meme gueulle, il y avait plusieur bouton command, puis par la suite j'ai supprimé des command, et du coup les noms se sont un peu melanger. je devrais avoir plus de rigueur sur ce point.
Autre sujet maintenant , je vais tenter de faire un programme dans lequel je vais rentrer des données du genre :
1er semaine je rentre quelques memos, semaine d'apres d'autres etc.. donc apres quelques semaines, les memos pouraient s'averer long car je desire les sauvegarder. donc je pense je vais devoir faire appel a des fichiers externes? le mieux serait un fichier excel, mais je voudrais que mon program puisse marcher sur un ordi ou meme excel n'est pas installé.. enfin j'attends vos remarques et vos liens qui me seront tres utiles.

Bonne année !!

Tcho

 Ajouter un commentaire


Discussions en rapport avec ce code source dans le forum

Renommer des dossiers à la chaine avec des contraintes... [ par SamyVW ] Oups, je n'avais pas vu qu'il y avait un forum spécialement prévu pour ma question... Je la repose donc ici, tout en m'excusant de laisser l'autre à s Remplacer dans une chaine de caractères à partir de la fin [ par daddyel ] Bonjour,Je souhaite dans une requête de mise à jour effectuer un "replace" en partant de la fin du champ (champ de longueur variable).Ainsi preg_replace pour chaine de code php [ par JoJo738 ] Bonjour, je fait un petit code php pour ameliorer le code php ( et surtout pour ne plus me faire gronger par Anthomicro ). Je viens juste de le sommen preg_replace pour chaine de code php [ par JoJo738 ] preg_replace pour chaine de code php [ par JoJo738 ] Renommer fichier dans un filelistbox ou autres sous VB6 [ par micmond ] Bonjour,J'ai Visual Basic 6.01. Renommer un fichier sous l'application Visual Basic J'ai une filelistbox qui affiche une liste de fichiers d'une direc Pb creation fonction remplacement de texte [ par kciope ] Bonjour tout le monde,je souhaite créer une fonction qui remplace certains caractère d'une chaine, voici ma fonction :     Public Function modif_titre preg_replace pour code php [ par JoJo738 ] Bonjour, je fait un petit code php pour ameliorer le code php ( et surtout pour ne plus me faire gronger par Anthomicro ). Je viens juste de le somme Faire un Replace sur une RichTextBox [ par lokomass ] Bonjour, J'aimerai automatiquement, qu'à chaque fois qu'une chaine de caractère apparait dans ma RTBox, elle soit remplacée par une autre. Comme ma R HS : Comment enregistrer par l'entrée audio ? [ par loic38760 ] J'ai une chaine Hi-Fi, j'e l'ai relié à l'aide d'un cable à l'entrée audio de la carte son mon ordinateur (prise bleue) mais


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Mars 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728
293031    

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 1,014 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales