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. 大数据【五】Hive(部署;表操作;分区)

    一 概述 就像我们所了解的sql一样,Hive也是一种数据仓库,不同的是hive是在hadoop大数据生态圈中所用.这篇博客我主要介绍Hive的简单表运用. Hive是Hadoop 大数据生态圈中的数 ...

  2. Unity Frame Debugger连接Android真机调试

    当用Profiler分析到不是代码导致的性能问题,当前场景最大的性能瓶颈是渲染时,或者自己写的Shader要调试时,都可以用Frame Debugger进行调试. 按下列步骤设置打包,既可以用Prof ...

  3. Python笔记(十三):urllib模块

    (一)      URL地址 URL地址组件 URL组件 说明 scheme 网络协议或下载方案 net_loc 服务器所在地(也许含有用户信息) path 使用(/)分割的文件或CGI应用的路径 p ...

  4. SQLSERVER群集故障转移笔记

    SQLSERVER群集故障转移笔记 出自<SQLSERVER2012实施与管理实战指南> SQLSERVER故障转移 P41 事实上,从sqlserver2000到sqlserver200 ...

  5. 如何在 Azure 中标记 Windows 虚拟机

    本文介绍在 Azure 中通过 Azure 资源管理器标记 Windows 虚拟机的不同方式.标记是用户定义的键/值对,可直接放置在资源或资源组中.针对每个资源和资源组,Azure 当前支持最多 15 ...

  6. 初识java内存区域

    目录: 1.运行时数据区域 2.对象的创建 3.对象的内存布局 4.对象的访问定位 一.运行时数据区域 基本的java虚拟机运行时数据区如下图: 下面我们就来逐个认识这几个运行时的数据区域 1.程序计 ...

  7. Java-Swing常用布局管理器

    http://www.cnblogs.com/hthuang/p/3460234.html   5.Java-Swing常用布局管理器       应用布局管理器都属于相对布局,各组件位置可随界面大小 ...

  8. linux 下获取文件最后几行

    在Linux下,获取文件倒数几行的命令是: tail -n 10 your_filename     #获取倒数10行

  9. 如何删除sharepoint列表List中的全部数据。

    可以使用excel,但是powershell会比较方便 (admin mode - Sharepoint powershell) [System.reflection.Assembly]::LoadW ...

  10. NoSQL——not onlySQL不仅仅是SQL

    数据有很大一部分是由关系数据库管理系统(RDBMS)来处理. 1970年 E.F.Codd's提出的关系模型的论文 "A relational model of data for large ...