Last active
May 20, 2019 20:27
-
-
Save gjreasoner/59cdc51b74fa96685b713ed23f4ef6d0 to your computer and use it in GitHub Desktop.
Download images in place
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
# Install: | |
# wget https://gist.githubusercontent.com/gjrdiesel/59cdc51b74fa96685b713ed23f4ef6d0/raw/Downloader.php -O /usr/local/bin/dl | |
# chmod +x /usr/local/bin/dl | |
if(!isset($argv[1])){ | |
echo "Downloader: This downloads the full URL and makes a matching file structure\n"; | |
die("Usage: dl [url]"); | |
} | |
$url = $argv[1]; | |
$path = ltrim(parse_url($url)['path'],'/'); | |
$file = basename($path); | |
$directory = str_replace($file,'',$path); | |
@mkdir($directory); | |
file_put_contents($path,file_get_contents($url)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment