VB 批量重命名文件
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 3 'Fixed Dialog
Caption = "Rename use VB QQ 1009374598"
ClientHeight = 3630
ClientLeft = 45
ClientTop = 435
ClientWidth = 9270
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3630
ScaleWidth = 9270
ShowInTaskbar = 0 'False
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "Go"
Height = 495
Left = 3600
TabIndex = 6
Top = 2400
Width = 1695
End
Begin VB.TextBox txtPreFix
Height = 405
Left = 1680
TabIndex = 4
Text = "Pic_"
Top = 1440
Width = 1215
End
Begin VB.TextBox txtDest
Height = 375
Left = 1680
TabIndex = 3
Top = 840
Width = 6855
End
Begin VB.TextBox txtSource
Height = 375
Left = 1680
TabIndex = 1
Top = 240
Width = 6855
End
Begin VB.Label Label2
Caption = "PreFix:"
Height = 375
Left = 360
TabIndex = 5
Top = 1440
Width = 1095
End
Begin VB.Label lbDest
Caption = "Dest Folder:"
Height = 375
Left = 240
TabIndex = 2
Top = 840
Width = 1215
End
Begin VB.Label Label1
Caption = "Source Folder"
Height = 255
Left = 240
TabIndex = 0
Top = 240
Width = 1335
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Private Declare Function GetPrivateProfileInt Lib "kernel32" Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Long, ByVal lpFileName As String) As Long
Dim configFile As String '读写INI例子:
Sub RWConfigFile()
'读字符串
Dim lng As Long
Dim retstr As String
retstr = String(260, 0)
lng = GetPrivateProfileString("config", "para1", "", retstr, 256, "c:\config.ini")
retstr = Replace(retstr, Chr(0), "") '读整数
lng = GetPrivateProfileInt("config", "para2", 0, "c:\config.ini") '写字符串
lng = WritePrivateProfileString("config", "para3", "写文件测试", "c:\config.ini")
End Sub Private Sub Form_Load() configFile = App.Path & "\config.ini"
loadConfig End Sub Sub loadConfig() Dim lng As Long
Dim retstr As String
retstr = String(260, 0)
lng = GetPrivateProfileString("config", "SourceFolder", "", retstr, 256, configFile)
retstr = Replace(retstr, Chr(0), "")
txtSource.Text = retstr retstr = String(260, 0)
lng = GetPrivateProfileString("config", "DestFolder", "", retstr, 256, configFile)
retstr = Replace(retstr, Chr(0), "")
txtDest.Text = retstr retstr = String(260, 0)
lng = GetPrivateProfileString("config", "PreFix", "", retstr, 256, configFile)
retstr = Replace(retstr, Chr(0), "")
txtPreFix.Text = retstr End Sub Sub saveConfig() Dim lng As Long lng = WritePrivateProfileString("config", "SourceFolder", txtSource.Text, configFile) lng = WritePrivateProfileString("config", "DestFolder", txtDest.Text, configFile) lng = WritePrivateProfileString("config", "PreFix", txtPreFix.Text, configFile) End Sub Private Sub Command1_Click() Dim files, names As String, i As Integer
Dim destFolder As String, sourceFolder As String
Dim ext As String
Dim preFix As String
On Error GoTo err
destFolder = txtDest.Text ' "C:\Documents and Settings\XPMUser\My Documents\My Pictures\avarta-80\OK\"
sourceFolder = txtSource.Text ' "C:\Documents and Settings\XPMUser\My Documents\My Pictures\avarta-80\"
preFix = txtPreFix.Text If Dir(sourceFolder, vbDirectory) = "" Then
MsgBox "Source folder not exists"
Exit Sub
End If If Dir(destFolder, vbDirectory) = "" Then
MkDir (destFolder)
End If
If Right(sourceFolder, 1) <> "\" Then sourceFolder = sourceFolder & "\"
files = Dir(sourceFolder)
Do While files <> ""
i = i + 1
names = files
'If LCase(Right(names, 4)) = ".jpg" Then
ext = Right(names, 4)
'Call FileCopy(sourceFolder & names, destFolder & " Pic_" & i & ".jpg")
Call FileCopy(sourceFolder & names, destFolder & "\" & preFix & i & ext)
' End If
files = Dir
Loop MsgBox "done " & i Exit Sub err:
MsgBox err.Description End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
saveConfig
End Sub
VB 批量重命名文件的更多相关文章
- Linux批量重命名文件
五种方法实现Linux批量重命名文件 Linux批量重命名文件是指对某些特定的文件统一进行重新命名,以改变原来一批文件的名称,这里介绍五种方法来实现. Linux批量重命名文件会涉及到改变一个字母.改 ...
- Linux命令行bash批量重命名文件
本文介绍下,在linux下使用shell批量重命名文件的例子,有需要的朋友参考下吧. 在linux中,重命名文件名,需要用到mv命令.如果需要批量重命名名一批文件,就需要写bash脚本或命令行了. 例 ...
- cmd - 批量重命名文件
相信大家或多或少都遇到过类似的情况:从网上下载了好多图片(或者其他的文件),这些图片的名字往往都是些乱七八糟的字母数字的组合,我们想要一次性修改几十张上百张的图片的名字应该怎么办呢? 这里有两种方法, ...
- [转]【Windows小技巧】批量重命名文件
注:如果文件名包含空格,命令应写成ren "s0 (1).gif" s001.gif,简而言之,就是加上双引号!!!原因:系统将s0和(1).gif认为是两个参数,再加上后面的s0 ...
- windows dos 批量重命名文件
描述 在工作中经常出现 在同一目录下有一些 很多相同扩展名的文件但是名字看起来很乱各不同,我们想将它们统一重命名一下统一的格式,如果一个个去改名字太麻烦了. 这里我门就可以使用windows下 dos ...
- 怎样用bat批量重命名文件夹和文件
很早以前本人写过重命名文件夹的文章,发现其中稍有不完善的地方,其主要功能在文件夹名前统一加上字符,或者在文件夹名后统一加上字符,有网友反应功能太单一.今天我又仔细研究了一下bat批处理代码,分别能完全 ...
- [转]Windows系统下批量重命名文件(bat命令版本)
原文地址:https://jingyan.baidu.com/article/6dad507524bdcba122e36e44.html 我们有时候会遇到大量文件需要重命名,Windows系统下右键菜 ...
- 【批处理】ren命令_批量重命名文件
[ren命令] 说明:ren是“rename(重命名)”的简写: 命令:REN [Drive:][path] <old filename> <new filename> 解释: ...
- linux 批量重命名文件
模拟结果文件路径结构大概是:/当前目录/模型名/字模型名模拟/模拟温度/模拟结果文件. 模拟结果文件命名时相同的.模拟结果文件需要修改模拟结果文件的后缀名. 附shell脚本: find -type ...
随机推荐
- SD从零开始05-06
SD从零开始5 从库存销售 销售凭证类型Sales document type: 用来鉴别和控制不同的业务流程类型: 标准的销售凭证类型: standard order: Rush order: Ca ...
- Nginx的站点目录及文件URL的访问控制
1.根据扩展名限制程序和文件访问: web2.0时代,绝大多数网站都是以用户为中心的,这些产品有一些共同点,就是不允许用户发布内容到服务器,还允许用户发图片甚至附件上传到服务器上,给用户开启了上传的功 ...
- Flutter:修改TextField的高度,以及无边框圆角
修改TextField的高度可以通过decoration: InputDecoration的contentPadding进行修改,代码如下 new TextField( decoration: Inp ...
- Android Studio 自动更新失败解决办法
Check Update一直提示Connection failed. Please check your network connection and try again,开始以为是由于G*W在捣乱, ...
- [Java][读书笔记]多线程编程
前言:最近复习java,发现一本很好的资料,<Java2参考大全 (第五版)> Herbert.Schildt.书比较老了,06年的,一些 ...
- UWP开发细节记录:加载图像文件到D2D位图和D3D纹理
在UWP中加载文件一般先创建 StorageFile 对象,然后调用StorageFile.OpenReadAsync 方法得到一个IRandomAccessStream 接口用来读取数据: Stor ...
- Eclipse+Weblogic 12开发简单的Enterprise Application
学到EJB方面的内容,遇到了很多问题,翻阅了无数遍Java EE和Weblogic的官方文档,在google上进行了无数次搜索都没有答案,可能我要找的答案太冷门.这一切都起源于Java EE官方文档里 ...
- CSS| position定位和float浮动
对基础知识再度做个巩固和梳理. 一.position定位 (一):position的属性 1.absolute:生成绝对定位的元素,相对于最近一级定位不是static的父元素来进行定位: 2.rela ...
- security/pam_appl.h:没有那个文件或目录
在编译开源库时, 提示 pam.h:4:10: 致命错误:security/pam_appl.h:没有那个文件或目录 #include <security/pam_appl.h> 解决方法 ...
- PyQt5--ToolBar
# -*- coding:utf-8 -*- ''' Created on Sep 14, 2018 @author: SaShuangYiBing ''' import sys from PyQt5 ...