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 ...
随机推荐
- SQL SERVER 将表字段值0和1互转的几种方法
需求: 如果表字段的值为 0 则将其修改为1 ,如果表字段的值为 1 则将其修改为 0. 方法一 end 方法二 ) 方法三 )
- 个人理解的Lambda表达式的演化过程
之前在组内进行过相关分享,为防止以后再单独整理,故在此将自己的PPT内容存放下. 所以,多数代码都是以图片的方式展现. 委托 什么是委托? 定义:委托是方法的抽象,它存储的就是一系列具有相同签名和返回 ...
- NodeJS配置TaoBao源
npm install -g cnpm --registry=https://registry.npm.taobao.org
- java截取电脑全屏
通过java代码截取电脑屏幕全屏代码如下: import java.awt.AWTException; import java.awt.Dimension; import java.awt.Recta ...
- Android5.x Notification应用解析
Notification可以让我们在获得消息的时候,在状态栏,锁屏界面来显示相应的信息,很难想象如果没有Notification,那我们的qq和微信以及其他应用没法主动通知我们,我们就需要时时的看手机 ...
- [Android] 图片裁剪总结——调用系统裁剪
花了两天时间看了下android的图片裁剪功能的实现.其实刚开始做这个我挺虚的,以为整个功能都需要自己写出来,但查了些资料,发现android已经提供了裁剪功能,需要的话自己调用就成了.soga,这下 ...
- PHP多进程编之pcntl_fork
其实PHP是支持并发的,只是平时很少使用而已.平时使用最多的应该是使用PHP-FMP调度php进程了吧. 但是,PHP的使用并不局限于做Web,我们完全也可以使用PHP来进行系统工具类的编程,做监控或 ...
- LeetCode题解之Longest Continuous Increasing Subsequence
1.题目描述 2.问题分析 从每一个num[i]往前扫描即可. 3.代码 int findLengthOfLCIS(vector<int>& nums) { ){ return n ...
- SQL Server 请求失败或服务未及时响应。有关详细信息,请参见事件日志或其它适合的错误日志
在打开数据库的时候,突然出现异常错误,然后我去关闭sql server 服务,然后重启服务的时候,不能重启,出现以下错误 “请求失败或服务未及时响应.有关详细信息,请参见事件日志或其它适合的错误日志” ...
- 简单实现MySQL数据库的日志审计
时间 2018-12-23 08:01:11 FreeBuf 原文 https://www.freebuf.com/articles/es/192062.html 主题 MySQL 0×0 背景 ...