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 批量重命名文件的更多相关文章

  1. Linux批量重命名文件

    五种方法实现Linux批量重命名文件 Linux批量重命名文件是指对某些特定的文件统一进行重新命名,以改变原来一批文件的名称,这里介绍五种方法来实现. Linux批量重命名文件会涉及到改变一个字母.改 ...

  2. Linux命令行bash批量重命名文件

    本文介绍下,在linux下使用shell批量重命名文件的例子,有需要的朋友参考下吧. 在linux中,重命名文件名,需要用到mv命令.如果需要批量重命名名一批文件,就需要写bash脚本或命令行了. 例 ...

  3. cmd - 批量重命名文件

    相信大家或多或少都遇到过类似的情况:从网上下载了好多图片(或者其他的文件),这些图片的名字往往都是些乱七八糟的字母数字的组合,我们想要一次性修改几十张上百张的图片的名字应该怎么办呢? 这里有两种方法, ...

  4. [转]【Windows小技巧】批量重命名文件

    注:如果文件名包含空格,命令应写成ren "s0 (1).gif" s001.gif,简而言之,就是加上双引号!!!原因:系统将s0和(1).gif认为是两个参数,再加上后面的s0 ...

  5. windows dos 批量重命名文件

    描述 在工作中经常出现 在同一目录下有一些 很多相同扩展名的文件但是名字看起来很乱各不同,我们想将它们统一重命名一下统一的格式,如果一个个去改名字太麻烦了. 这里我门就可以使用windows下 dos ...

  6. 怎样用bat批量重命名文件夹和文件

    很早以前本人写过重命名文件夹的文章,发现其中稍有不完善的地方,其主要功能在文件夹名前统一加上字符,或者在文件夹名后统一加上字符,有网友反应功能太单一.今天我又仔细研究了一下bat批处理代码,分别能完全 ...

  7. [转]Windows系统下批量重命名文件(bat命令版本)

    原文地址:https://jingyan.baidu.com/article/6dad507524bdcba122e36e44.html 我们有时候会遇到大量文件需要重命名,Windows系统下右键菜 ...

  8. 【批处理】ren命令_批量重命名文件

    [ren命令] 说明:ren是“rename(重命名)”的简写: 命令:REN [Drive:][path] <old filename> <new filename> 解释: ...

  9. linux 批量重命名文件

    模拟结果文件路径结构大概是:/当前目录/模型名/字模型名模拟/模拟温度/模拟结果文件. 模拟结果文件命名时相同的.模拟结果文件需要修改模拟结果文件的后缀名. 附shell脚本: find -type ...

随机推荐

  1. Ubuntu16.04搭建kubernetes v1.11.2集群

    1.节点介绍         master      cluster-1      cluster-2      cluster-3 hostname        k8s-55      k8s-5 ...

  2. WOSA/XFS PTR Form解析库—xfsptrdata.h

    #ifndef _XFSPTRDATA_H_#define _XFSPTRDATA_H_ #include <XFSPTR.H>#include <Windows.h>#inc ...

  3. 8 张脑图入门 JavaScript - 基础面试不倒

    8 张脑图入门 JavaScript - 基础面试不倒 转载请注明出处 第一:JavaScript 的变量 第二:JavaScript 运算符 第三:JavaScript 数组 第四:JavaScri ...

  4. react native 第一次下载app的欢迎页+每次启动app的启动页设计

    欢迎各位同学加入: React-Native群:397885169 大前端群:544587175 大神超多,热情无私帮助解决各种问题. 我想我写的这篇博文可以帮助到很多人,接下来要分享的东西,对app ...

  5. go语言练习:结构体

    package main import "fmt" type book struct { title string author string page int } func ma ...

  6. LeetCode题解之Rotate String

    1.题目描述 2.问题分析 直接旋转字符串A,然后做比较即可. 3.代码 bool rotateString(string A, string B) { if( A.size() != B.size( ...

  7. SQLSERVER中的元数据锁

    SQLSERVER中的元数据锁 网上对于元数据锁的资料真的非常少 元数据锁一般会出现在DDL语句里 下面列出数据库引擎可以锁定的资源 资源 说明 RID 用于锁定堆(heap)中的某一行 KEY 用于 ...

  8. 结合 spring 使用阿里 Druid 连接池配置方法

    1.数据源 <!-- 配置数据源 --> <bean name="dataSource" class="com.alibaba.druid.pool.D ...

  9. Windows2003系统如何设置能让两个人共用一个桌面同时远程控制?

    在windows 2003上,可以两人同时同一桌面控制一台服务器,交流非常方便. 解决方案: 两人都用终端远程登陆到服务器上,其中一人在“开始”--“管理工具”--“终端服务管理器”,选中对方的用户名 ...

  10. sql 经典面试题及答案(选课表)

    SQL数据库面试题以及答案 Student(Sno,Sname,Sage,Ssex) 学生表       Sno:学号:Sname:学生姓名:Sage:学生年龄:Ssex:学生性别Course(Cno ...