Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename script for Windows users #6

Closed
wants to merge 1 commit into from
Closed

Rename script for Windows users #6

wants to merge 1 commit into from

Conversation

sergant210
Copy link
Member

Скрипт переименования для пользователей Windows.

Скрипт переименования для пользователей Windows
@sergant210 sergant210 closed this Apr 12, 2015
@sergant210 sergant210 reopened this Apr 12, 2015
@bezumkin
Copy link
Collaborator

Лучше изменить родной php скрипт переименования, чтобы он работал и в Windows.

У меня просто давно его нет, чтобы проверять. А держать 2 одинаковых скрипта под разные ОС неправильно.

@cooland
Copy link

cooland commented Dec 27, 2015

Я себе вот так сделал

From 40c2d44a87a3f327a07a4307f2ea42d83bb04c4c Mon Sep 17 00:00:00 2001
From: cooland
Date: Sun, 27 Dec 2015 20:42:12 +0300
Subject: [PATCH] Fix for windows platform


rename_it.php | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/rename_it.php b/rename_it.php
index 2ad0303..ecc40d4 100644
--- a/rename_it.php
+++ b/rename_it.php
@@ -25,9 +25,9 @@ $old_name_lower = strtolower($old_name);
$dirs = scandir($start);

-$tmp = explode('/', $start);
+$tmp = explode(DIRECTORY_SEPARATOR, $start);
array_pop($tmp);
-$end = implode('/', $tmp) . '/' . $new_name;
+$end = implode(DIRECTORY_SEPARATOR, $tmp) . DIRECTORY_SEPARATOR . $new_name;
@rename($start, $end);
rename_extra($end, array($old_name, $old_name_lower), array($new_name, $new_name_lower));

@@ -49,10 +49,10 @@ function rename_extra($start_path, $find = array(), $replace = array()) {
continue;
}

  •   $old_path = str_replace('//', '/', $start_path . '/' . $item);
    
  •   $old_path = str_replace('//', DIRECTORY_SEPARATOR, $start_path . DIRECTORY_SEPARATOR . $item);
    
    if (strpos($old_path, $find[1]) !== false) {
    
  •       $new_path = str_replace('//', '/', $start_path . '/' . str_replace($find, $replace, $item));
    
  •       $new_path = str_replace('//', DIRECTORY_SEPARATOR, $start_path . DIRECTORY_SEPARATOR . str_replace($find, $replace, $item));
        if (!rename($old_path, $new_path)) {
            exit("\nCould not rename $old_path to $new_path");
        }
    
    --
    2.6.4.windows.1

bezumkin added a commit that referenced this pull request Nov 19, 2017
- Removed shell renaming script.
@bezumkin bezumkin closed this Nov 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants