-
-
Save 0x0dea/bbc45e4265ff5d6185a7 to your computer and use it in GitHub Desktop.
This file contains 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
foo $ tree | |
. | |
├── a | |
│ ├── 1.m4a | |
│ ├── 1.mp3 | |
│ └── 2.mp3 | |
├── b | |
│ ├── 3.m4a | |
│ ├── 3.mp3 | |
│ ├── 4.mp3 | |
│ ├── 5.m4a | |
│ └── 5.mp3 | |
├── c | |
│ ├── 6.mp3 | |
│ ├── 7.m4a | |
│ ├── 7.mp3 | |
│ ├── 8.m4a | |
│ └── 8.mp3 | |
└── sad.rb | |
3 directories, 14 files | |
foo $ | |
foo $ ruby sad.rb | |
["a/1.m4a", "b/5.m4a", "b/3.m4a", "c/8.m4a", "c/7.m4a"] | |
foo $ | |
foo $ cat sad.rb | |
require 'fileutils' | |
m4a = Dir['**/*.m4a'] | |
mp3 = Dir['**/*.mp3'] | |
have = m4a & mp3.map { |f| f.sub /mp3$/, 'm4a' } | |
p have | |
# FileUtils.rm have |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
m4a = Dir['/*.m4a']
mp3 = Dir['/*.mp3']
File.dirname(mp3) + '/' + File.basename(mp3).split.('.')[0]