|
Trouver une ressource
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
PROGRAMME POUR RENOMMER PLUSIEUR FICHIER
Information sur la source
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
Historique
- 01 janvier 2008 15:10:41 :
- voici le .zip
Sources de la même categorie
Sources en rapport avec celle ci
Commentaires et avis
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 ]
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
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
Modifier le contenu d'une cellule (chaine de caractère) [ par muenchner ]
Bonjour,j'aimerai savoir comment modifier une chaine de caractère.Dans mon cas, j'ai une cellule qui comprend par exemple "1000 kWh" et je veux recopi
Treeview et Checkbox [ par supertoms ]
Salut à tous,après beaucoup de recherches et de difficultés j'ai enfin réussi à créer une treeview en vba, et à mettre des cases à cocher à chaque élé
|
Téléchargements
Logiciels à télécharger sur le même thème :
|