Home Backend Development PHP Tutorial PHP file batch rename file batch rename tool win7 batch rename files batch folder rename ba

PHP file batch rename file batch rename tool win7 batch rename files batch folder rename ba

Jul 29, 2016 am 08:52 AM
php file Batch rename

$format ='jpg';
                    $path ='C:/Users/12759/Desktop/5.30.120.0';
                    $files = $this->getfile($path,$format);
                    foreach( $files as  $v )
                    {

                    /* //$tv = basename($v);
                     //dd($tv);*/
                     $aa = pathinfo($v);
                     //dd($aa);
                     //list($name,$ext) = explode('.',$tv);
                     //$newname =$path.time().mt_rand(1,10000).'.'.$ext;*/
                     $newname = md5($aa['filename']).'.'.$aa['extension'];
                     //dd($newname);
                    /* if(rename($v,$newname))
                     {
                      echo '成功将'.$v.'重命名'.$newname.'<br />'; 
                     }*/

                     rename($path.'/'.$v,$path.'/'.$newname);    
                     /*echo '成功将'.$v.'重命名'.$newname.'<br />'; */
                     echo "<span style=&#39;color:red&#39;>".$v."</span>"."--------------".$newname."<br/>";

                    }




public function getfile($dirname,$format)
    {
             $dirs    = array();
             $handle = opendir($dirname);
             while(($fn = readdir($handle))!==false){
                 if($fn!='.'&&$fn!='..'){
                 $curDir = $dirname.'/'.$fn;  
                $path = pathinfo($curDir);
                 $dirs[] = $path['basename'];

              }
            }

             return $dirs;
    }
Copy after login

The above introduces the batch renaming of PHP files, including the contents of PHP files and batch renaming. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to open php files on mobile phone How to open php files on mobile phone Nov 13, 2023 am 11:08 AM

To open a php file on a mobile phone, you need to set up a server environment that can run php on the mobile phone and upload the php file to the server. Then, enter the IP address or domain name of the server, plus the path to the php file, into the browser on your phone to open the php file and view its contents.

How to deal with case errors in PHP file paths and generate corresponding error messages How to deal with case errors in PHP file paths and generate corresponding error messages Aug 08, 2023 pm 09:45 PM

How to deal with case errors in PHP file paths and generate corresponding error messages. In the process of developing PHP programs, we often encounter the problem of case errors in file paths. Since Windows and Linux systems handle file path case differently, when the program passes the test using the Windows system in the development environment, it may cause path errors when it is deployed to the Linux server. In order to solve this problem, we can use some methods to deal with the large file path

How to open php file How to open php file Sep 01, 2023 am 11:53 AM

Steps to open a php file: 1. Select a text editor; 2. Create a new file in the selected text editor and save it as a .php file; 3. Write PHP code in the created PHP file; 4. To run PHP files on your local computer, you need to set up a server environment; 5. After installing the server environment, you need to put the PHP files into the server directory; 6. Once you put the PHP files into the server directory, you can browse server to run it.

How to batch rename files in win10 How to batch rename files in win10 Mar 01, 2024 pm 06:31 PM

The win10 system has very complete functions, so even though win11 has been released, many users choose to use the win10 system. However, many friends do not know how to batch rename files. Next, the editor will help everyone solve this problem. How to batch rename files in win10 1. First select the folder that needs to be edited, then right-click and select Open in the interface. 2. After entering the folder, you need to hold down the ctrl key and select all the files that need to be renamed. 3. Then right-click the file and select the rename option in the pop-up menu. 4. Then select a file to rename, and click the Enter key after entering the file name. 5. Finally, the system will automatically rename. After the naming is completed, the files will be automatically classified.

Several aspects of content can be included in the .php file Several aspects of content can be included in the .php file Mar 06, 2023 pm 05:32 PM

What can be included in the php file: 1. The starting tag "<?php" and the ending tag "?>", all PHP code must be written inside this pair of tags; 2. The semicolon ";" is a PHP statement The delimiter also represents the instruction for code execution; 3. Comments, including single-line comments "//", multi-line comments "/* */", and Shell comments "#"; 4. Line breaks, which can Enhance the readability of the code; 5. Code segments (such as functions, etc.).

how to open php file how to open php file Jan 24, 2024 pm 04:12 PM

Tools for opening php files: 1. Notepad++; 2. Sublime Text; 3. Visual Studio Code; 4. Eclipse; 5. XAMPP. Detailed introduction: 1. Notepad++, which is a free text editor that supports multiple programming languages, including PHP. It has functions such as syntax highlighting and code folding, making it easier to read and edit PHP code; 2. Sublime Text , a powerful text editor and more.

What code can a PHP file contain? What code can a PHP file contain? Aug 01, 2023 pm 01:34 PM

PHP files can contain code: 1. PHP code, used to complete various server-side tasks; 2. HTML code, used to define the structure and layout of the web page; 3. CSS code, used to define the style of the web page; 4. JavaScript Code, used to implement various dynamic interaction functions in web pages; 5. SQL code, used to operate the database; 6. The file contains code, which can modularize the code; 7. Third-party libraries and frameworks, which can be quickly constructed Feature-rich application.

How to batch rename image files using PHP How to batch rename image files using PHP Aug 17, 2023 pm 06:01 PM

How to use PHP to batch rename image files When processing image files, sometimes you will encounter situations where you need to rename image files in batches. As a powerful server-side scripting language, PHP provides a wealth of file processing functions and operation methods, which can easily realize the batch renaming function of image files. This article will introduce how to use PHP to batch rename image files and provide corresponding code examples. First, we need to clarify the requirements to be achieved: rename all image files in the specified directory into a unified format, for example, according to "Picture

See all articles